diff --git a/test/vuex/acc-beginning-balance/api/balance.js b/test/vuex/acc-beginning-balance/api/balance.js new file mode 100644 index 0000000..13be0d6 --- /dev/null +++ b/test/vuex/acc-beginning-balance/api/balance.js @@ -0,0 +1,164 @@ +const URL = "/one-api/mockup/masterdata/accounting/Beginingbalance"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + '/getPeriode', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function save(prm) { + try { + var resp = await axios.post(URL + '/save', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function addData(prm) { + try { + var resp = await axios.post(URL + '/addData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function search(prm) { + try { + var resp = await axios.post(URL + '/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function cek(prm) { + try { + var resp = await axios.post(URL + '/cek', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function updateData(prm) { + try { + var resp = await axios.post(URL + '/updateData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function deleteData(prm) { + try { + var resp = await axios.post(URL + '/delete', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchCoa(prm) { + try { + var resp = await axios.post(URL + '/searchCoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function postData(prm) { + try { + var resp = await axios.post(URL + '/postData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-beginning-balance/api/patient.js b/test/vuex/acc-beginning-balance/api/patient.js new file mode 100644 index 0000000..918af7a --- /dev/null +++ b/test/vuex/acc-beginning-balance/api/patient.js @@ -0,0 +1,347 @@ +const URL = "/one-api/mockup/mcuoffline/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'preregister/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function generatesetup(prm) { + try { + var resp = await axios.post(URL + 'preregister/generatesetup', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getsexreg(token) { + try { + var resp = await axios.post(URL + 'preregister/getsexreg',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(prm) { + try { + var resp = await axios.post(URL + 'preregister/save',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function newpatient(prm) { + try { + var resp = await axios.post(URL + 'preregister/newpatient',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(prm) { + try { + var resp = await axios.post(URL + 'preregister/deletepatient',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getaddress(prm) { + try { + var resp = await axios.post(URL + 'preregister/getaddress',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchcity(token,prm) { + try { + var resp = await axios.post(URL + 'preregister/searchcity',{token:token,search:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function getdistrict(token,prm) { + try { + var resp = await axios.post(URL + 'preregister/getdistrict',{id:prm.M_CityID,token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function getkelurahan(token,prm) { + try { + var resp = await axios.post(URL + 'preregister/getkelurahan',{token:token,id:prm.M_DistrictID}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + +export async function savenewaddress(prm) { + try { + var resp = await axios.post(URL + 'preregister/savenewaddress',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveeditaddress(prm) { + try { + var resp = await axios.post(URL + 'preregister/saveeditaddress',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteaddress(prm) { + try { + var resp = await axios.post(URL + 'preregister/deleteaddress',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function searchdoctor(prm) { + try { + console.log('aye') + console.log(prm) + var resp = await axios.post(URL + 'preregister/searchdoctor',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function searchcompany(prm) { + try { + var resp = await axios.post(URL + 'preregister/searchcompany',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getmou(prm) { + try { + var resp = await axios.post(URL + 'preregister/getmou',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function savepreregister(prm) { + try { + var resp = await axios.post(URL + 'preregister/savepreregister',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function gotoreg(prm) { + try { + var resp = await axios.post(URL + 'preregister/gotoreg',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } \ No newline at end of file diff --git a/test/vuex/acc-beginning-balance/components/VueCsvImport.vue b/test/vuex/acc-beginning-balance/components/VueCsvImport.vue new file mode 100644 index 0000000..30a5058 --- /dev/null +++ b/test/vuex/acc-beginning-balance/components/VueCsvImport.vue @@ -0,0 +1,293 @@ + + + diff --git a/test/vuex/acc-beginning-balance/components/oneBalance.vue b/test/vuex/acc-beginning-balance/components/oneBalance.vue new file mode 100644 index 0000000..73eee61 --- /dev/null +++ b/test/vuex/acc-beginning-balance/components/oneBalance.vue @@ -0,0 +1,856 @@ + + + + + diff --git a/test/vuex/acc-beginning-balance/components/oneMdPatientAddress.vue b/test/vuex/acc-beginning-balance/components/oneMdPatientAddress.vue new file mode 100644 index 0000000..6b33d32 --- /dev/null +++ b/test/vuex/acc-beginning-balance/components/oneMdPatientAddress.vue @@ -0,0 +1,397 @@ + + + + + diff --git a/test/vuex/acc-beginning-balance/components/oneMdPatientDetail.vue b/test/vuex/acc-beginning-balance/components/oneMdPatientDetail.vue new file mode 100644 index 0000000..03055fd --- /dev/null +++ b/test/vuex/acc-beginning-balance/components/oneMdPatientDetail.vue @@ -0,0 +1,183 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-beginning-balance/components/oneMdPatientList.vue b/test/vuex/acc-beginning-balance/components/oneMdPatientList.vue new file mode 100644 index 0000000..f80d992 --- /dev/null +++ b/test/vuex/acc-beginning-balance/components/oneMdPatientList.vue @@ -0,0 +1,543 @@ + + + + diff --git a/test/vuex/acc-beginning-balance/csv-mcu.csv b/test/vuex/acc-beginning-balance/csv-mcu.csv new file mode 100644 index 0000000..50c9710 --- /dev/null +++ b/test/vuex/acc-beginning-balance/csv-mcu.csv @@ -0,0 +1,3 @@ +PID,NAMA,TANGGAL_LAHIR,JENIS_KELAMIN,NIK,JABATAN,EMAIL,HP,LOKASI,JOB,KEDUDUKAN +,AA,12-09-2001,P,,GURU,,,,, +,BB,14-01-1994,L,12.14.44.55,DIRKEU,,,,, diff --git a/test/vuex/acc-beginning-balance/csv-mcu.xls b/test/vuex/acc-beginning-balance/csv-mcu.xls new file mode 100644 index 0000000..83a809e Binary files /dev/null and b/test/vuex/acc-beginning-balance/csv-mcu.xls differ diff --git a/test/vuex/acc-beginning-balance/csv-mcu.xlsx b/test/vuex/acc-beginning-balance/csv-mcu.xlsx new file mode 100644 index 0000000..b131b5a Binary files /dev/null and b/test/vuex/acc-beginning-balance/csv-mcu.xlsx differ diff --git a/test/vuex/acc-beginning-balance/index.php b/test/vuex/acc-beginning-balance/index.php new file mode 100644 index 0000000..a384804 --- /dev/null +++ b/test/vuex/acc-beginning-balance/index.php @@ -0,0 +1,119 @@ + + + + + + + + One + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-beginning-balance/modules/balance.js b/test/vuex/acc-beginning-balance/modules/balance.js new file mode 100644 index 0000000..9781938 --- /dev/null +++ b/test/vuex/acc-beginning-balance/modules/balance.js @@ -0,0 +1,411 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/balance.js" + +export default { + namespaced: true, + state: { + last_id: -1, + loading: false, + cek: false, + dataUpload: [], + status: 'N', + snackbar: { + state: false, + color: 'success', + msg: '' + }, + periodeList: [ + { + "id": '1', "name": "periode Januari", "periode": '01-01-2024 - 31-01-2024' + }, + { + "id": '2', "name": "periode Februari", "periode": '01-02-2024 - 31-02-2024' + } + ], + selectedPeriode: {}, + data: [ + { + "number": '101101001', + "keterangan": 'Bank BCA 742-599-268899', + "value": '1500000', + "type": 'DB', + "input": 1 + }, + { + "number": '101101002', + "keterangan": 'Bank', + "value": '1500000', + "type": 'CR', + "input": 1 + }, + ], + summary: { debit: "1500000", credit: "1500000", balance: "1500000" }, + dialogEdit: false, + dialogImport: false, + dialogAdd: false, + loadingAutocomplete: false, + coaList: [], + selectedCoa: {}, + searchCoa: '' + }, + mutations: { + update_periodeList(state, val) { + state.periodeList = val + }, + update_selectedPeriode(state, val) { + state.selectedPeriode = val + }, + update_data(state, val) { + state.data = val + }, + update_dialogEdit(state, val) { + state.dialogEdit = val + }, + update_dialogImport(state, val) { + state.dialogImport = val + }, + update_summary(state, val) { + state.summary = val + }, + update_loading(state, val) { + state.loading = val + }, + update_cek(state, val) { + state.cek = val + }, + update_dataUpload(state, val) { + state.dataUpload = val + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val + }, + update_coaList(state, val) { + state.coaList = val + }, + update_selectedCoa(state, val) { + state.selectedCoa = val + }, + update_searchCoa(state, val) { + state.searchCoa = val + }, + update_dialogAdd(state, val) { + state.dialogAdd = val + }, + update_status(state, val) { + state.status = val + }, + update_snackbar(state, val) { + state.snackbar = val + }, + }, + actions: { + async getPeriode(context) { + context.commit("update_loading", true) + try { + let prm = {} + prm.token = one_token() + let resp = await api.getPeriode(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + } else { + context.commit("update_loading", false) + context.commit("update_periodeList", resp.data) + console.log(resp.data); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async addData(context, prm) { + context.commit("update_loading", true) + try { + prm.periode = context.state.selectedPeriode; + prm.token = one_token() + let resp = await api.addData(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.commit("update_loading", false) + context.dispatch("search"); + context.commit("update_dialogAdd", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil tambah data' + } + context.commit("update_snackbar", snackbar) + + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error add data' + } + context.commit("update_snackbar", snackbar) + console.log('error add data') + } + }, + async save(context, prm) { + context.commit("update_loading", true) + try { + prm.periode = context.state.selectedPeriode; + prm.token = one_token() + let resp = await api.save(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.commit("update_loading", false) + context.dispatch("search"); + context.commit("update_dialogImport", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil simpan data' + } + context.commit("update_snackbar", snackbar) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'error', + msg: "Error save" + } + context.commit("update_snackbar", snackbar) + console.log(e) + } + }, + async postData(context) { + context.commit("update_loading", true) + try { + let prm = {} + prm.token = one_token() + let resp = await api.postData(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + context.commit("update_loading", false) + context.dispatch("search"); + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil post data' + } + context.commit("update_snackbar", snackbar) + + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'error', + msg: "Error post data" + } + context.commit("update_snackbar", snackbar) + console.log(e) + } + }, + async search(context) { + context.commit("update_loading", true) + try { + let prm = {} + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + context.commit("update_loading", false) + context.commit("update_data", resp.data.data) + context.commit("update_summary", resp.data.total) + context.commit("update_selectedPeriode", resp.data.periode) + context.commit("update_status", resp.data.status) + } + } catch (e) { + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'error', + msg: "Error Search" + } + context.commit("update_snackbar", snackbar) + console.log(e) + } + }, + async cek(context) { + context.commit("update_loading", true) + try { + let prm = {} + prm.token = one_token() + let resp = await api.cek(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp) + } else { + console.log(resp); + context.commit("update_loading", false) + let cek = 0; + if (parseInt(resp.data) > 0) { + cek = true + } + context.commit("update_cek", cek) + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async updateData(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.updateData(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + // context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.dispatch("search") + context.commit("update_dialogEdit", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil update data' + } + context.commit("update_snackbar", snackbar) + + } + } catch (e) { + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'error', + msg: "Error update data" + } + context.commit("update_snackbar", snackbar) + console.log(e) + } + }, + async deleteData(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.deleteData(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + // context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil hapus data' + } + context.commit("update_snackbar", snackbar) + context.dispatch("search") + // context.commit("update_dialogEdit", false) + + } + } catch (e) { + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'error', + msg: "Error delete data" + } + context.commit("update_snackbar", snackbar) + console.log(e) + } + }, + async searchCoa(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoa; + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + + context.commit("update_coaList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-beginning-balance/modules/patient.js b/test/vuex/acc-beginning-balance/modules/patient.js new file mode 100644 index 0000000..6d8c114 --- /dev/null +++ b/test/vuex/acc-beginning-balance/modules/patient.js @@ -0,0 +1,740 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/patient.js" + +export default { + namespaced: true, + state: { + last_id: -1, + last_saved_id: -1, + x_addr_id: 0, + act: 'edit', + act_addr: 'new', + get_data_status: 0, + search_patient: 0, + search_status: 0, + search_error_message: '', + norm: '', + patient_prefix: '', + patient_name: '', + patient_suffix: '', + titles: [], + selected_title: {}, + dob: '', + patients: [], + total_patients: 0, + patient_address: [], + sexes: [], + selected_sex: {}, + religions: [], + selected_religion: {}, + phone: '', + hp: '', + email: '', + pob: '', + kartuidentitass: [], + selected_kartuidentitas: {}, + noidentitas: '', + note: '', + nik: '', + jabatan: '', + kedudukan: '', + pj: '', + location: '', + job: '', + total_patient: 0, + selected_patient: {}, + save_status: 0, + btn_save_seen: true, + pgrs_save: false, + save_error_message: '', + no_save: 0, + open_alert_confirmation: false, + alert_success: false, + msg_success: "", + dialog_success: false, + dialog_confirmation_delete: false, + msg_confirmation_delete: "", + dialog_confirmation_delete_addr: false, + msg_confirmation_delete_addr: "", + autocomplete_status: 0, + dialog_form_address: false, + label_address: '', + addresses: [], + cities: [], + city_address: {}, + companies:[], + company:{}, + mous:[], + mou:{}, + doctors:[], + doctor:{}, + districts: [], + district_address: {}, + kelurahans: [], + kelurahan_address: {}, + description_address: '', + errors: [], + current_page:1, + autocomplete_status:0, + status:{id:"N",name:"Belum di download"}, + start_date:moment(new Date()).format('YYYY-MM-DD'), + end_date:moment(new Date()).format('YYYY-MM-DD'), + selected_mous:[], + selected_doctors:[], + xid:-1, + csv_json:[], + data_setup:{}, + default_mu :{}, + default_doctor:{}, + setupcode:'', + search:'' + }, + mutations: { + update_search(state,val){ + state.search = val + }, + update_setupcode(state,val){ + state.setupcode = val + }, + update_default_mu(state,val){ + state.default_mu = val + }, + update_default_doctor(state,val){ + state.default_doctor = val + }, + update_data_setup(state,val){ + state.data_setup = val + }, + update_csv_json(state,val){ + state.csv_json = val + }, + update_xid(state,val){ + state.xid = val + }, + update_selected_doctors(state,val){ + state.selected_doctors = val + }, + update_selected_mous(state,val){ + state.selected_mous = val + }, + update_companies(state,val){ + state.companies = val + }, + update_company(state,val){ + state.company = val + }, + update_mous(state,val){ + state.mous = val + }, + update_mou(state,val){ + state.mou = val + }, + update_doctors(state,val){ + state.doctors = val + }, + update_doctor(state,val){ + state.doctor = val + }, + update_autocomplete_status(state,val){ + state.autocomplete_status = val + }, + update_start_date(state, val) { + state.start_date = val + }, + update_end_date(state, val) { + state.end_date = val + }, + update_status(state, val) { + state.status = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_x_addr_id(state, val) { + state.x_addr_id = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_last_saved_id(state, val) { + state.last_saved_id = val + }, + update_act(state, val) { + state.act = val + }, + update_act_addr(state, val) { + state.act_addr = val + }, + update_get_data_status(state, val) { + state.get_data_status = val + }, + update_search_error_message(state, patient) { + state.search_error_message = patient + }, + update_search_patient(state, patient) { + state.search_patient = patient + }, + update_dob(state, val) { + state.dob = val + }, + update_patient_prefix(state, val) { + state.patient_prefix= val + }, + update_patient_name(state, val) { + state.patient_name = val + }, + update_patient_suffix(state, val) { + state.patient_suffix = val + }, + update_norm(state, val) { + state.norm = val + }, + update_titles(state, val) { + state.titles = val + }, + update_selected_title(state, val) { + state.selected_title = val + }, + update_patients(state, data) { + state.patients = data + }, + update_selected_patient(state, val) { + state.selected_patient = val + }, + update_sexes(state, val) { + state.sexes = val + }, + update_selected_sex(state, val) { + state.selected_sex = val + }, + update_religions(state, val) { + state.religions = val + }, + update_selected_religion(state, val) { + state.selected_religion = val + }, + update_phone(state, val) { + state.phone = val + }, + update_email(state, val) { + state.email = val + }, + update_pob(state, val) { + state.pob = val + }, + update_hp(state, val) { + state.hp = val + }, + update_kartuidentitass(state, val) { + state.kartuidentitass = val + }, + update_selected_kartuidentitas(state, val) { + state.selected_kartuidentitas = val + }, + update_noidentitas(state, val) { + state.noidentitas = val + }, + update_note(state, val) { + state.note = val + }, + update_nik(state, val) { + state.nik = val + }, + update_jabatan(state, val) { + state.jabatan = val + }, + update_kedudukan(state, val) { + state.kedudukan = val + }, + update_pj(state, val) { + state.pj = val + }, + update_location(state, val) { + state.location = val + }, + update_job(state, val) { + state.job = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_btn_save_seen(state, val) { + state.btn_save_seen = val + }, + update_pgrs_save(state, val) { + state.pgrs_save = val + }, + update_save_error_message(state, msg) { + state.save_error_message = '' + }, + update_no_save(state, val) { + state.no_save = val + }, + update_open_alert_confirmation(state, val) { + state.open_alert_confirmation = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_dialog_success(state, val) { + state.dialog_success = val + }, + update_dialog_confirmation_delete(state, val) { + state.dialog_confirmation_delete = val + }, + update_msg_confirmation_delete(state, val) { + state.msg_confirmation_delete = val + }, + update_dialog_confirmation_delete_addr(state, val) { + state.dialog_confirmation_delete_addr = val + }, + update_msg_confirmation_delete_addr(state, val) { + state.msg_confirmation_delete_addr = val + }, + update_addresses(state, val) { + state.addresses = val + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val + }, + update_dialog_form_address(state, val) { + state.dialog_form_address = val + }, + update_label_address(state, val) { + state.label_address = val + }, + update_cities(state, val) { + state.cities = val + }, + update_city_address(state, val) { + state.city_address = val + }, + update_districts(state, val) { + state.districts = val + }, + update_district_address(state, val) { + state.district_address = val + }, + update_kelurahans(state, val) { + state.kelurahans = val + }, + update_kelurahan_address(state, val) { + state.kelurahan_address = val + }, + update_description_address(state, val) { + state.description_address = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_errors(state, val) { + state.errors = val + }, + update_total_patients(state, val) { + state.total_patients = val + }, + update_total_patient(state, val) { + state.total_patient = val + } + }, + actions: { + async generatesetup(context,prm) { + context.commit("update_get_data_status", 1) + try { + prm.token = one_token() + let resp = await api.generatesetup(prm) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + } else { + context.commit("update_get_data_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + console.log(resp.data.records) + context.commit("update_data_setup", resp.data.records) + context.commit("update_setupcode", '') + context.commit("update_current_page", 1) + //context.commit("update_patients", data.records['patients']) + context.dispatch("search", { + search:'', + xid:context.state.data_setup.McuOfflinePrepareID, + current_page: 1, + lastid: -1 + }) + } + } catch (e) { + context.commit("update_get_data_status", 3) + } + }, + async search(context, prm) { + context.commit("update_search_patient", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_patient", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_patient", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_patients", data.records) + context.commit("update_total_patient", data.total) + context.commit("update_no_save", 0) + + //context.commit("update_data_setup", resp.data.setup) + + } + } catch (e) { + context.commit("update_search_patient", 3) + context.commit("update_search_error_message", e.message) + console.log(e) + } + }, + async getsexreg(context) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.getsexreg(one_token()) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + } else { + context.commit("update_get_data_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_sexes", data.records.sexes) + context.commit("update_religions", data.records.religions) + context.commit("update_titles", data.records.titles) + context.commit("update_kartuidentitass", data.records.kartuidentitass) + } + } catch (e) { + context.commit("update_get_data_status", 3) + } + }, + async savecsv(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + //location.reload() + context.dispatch("search", { + search:'', + xid:context.state.data_setup.McuOfflinePrepareID, + current_page: 1, + lastid: -1 + }) + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async gotoreg(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.gotoreg(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + var pre_id = prm.Mcu_PreregisterDetailsID + location.replace("/one-ui/test/vuex/one-fo-registration-v8/" + "?pre_id=" +pre_id) + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async newpatient(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.newpatient(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + console.log(resp.data.id) + context.commit("update_last_id", resp.data.id) + context.commit("update_dialog_success", true) + var msg = "Data pasien " + prm.M_PatientName + " sudah tersimpan dong ..." + context.commit("update_msg_success", msg) + + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.xdelete(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + context.commit("update_last_id", 0) + context.commit("update_dialog_confirmation_delete", false) + context.commit("update_dialog_success", true) + var msg = "Data setup " + prm.code + " sudah dihapus dong ..." + context.commit("update_msg_success", msg) + context.commit("update_company", {}) + context.commit("update_selected_mous", []) + context.commit("update_mou", {}) + context.commit("update_selected_doctors", []) + context.commit("update_start_date", moment(new Date()).format('YYYY-MM-DD')) + context.commit("update_end_date", moment(new Date()).format('YYYY-MM-DD')) + context.commit("update_default_mou", {}) + context.commit("update_default_doctor", {}) + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async getaddress(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.getaddress(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_addresses", data.records) + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async savesetup(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.savesetup(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_company", {}) + context.commit("update_selected_mous", []) + context.commit("update_mou", {}) + context.commit("update_selected_doctors", []) + context.commit("update_start_date", moment(new Date()).format('YYYY-MM-DD')) + context.commit("update_end_date", moment(new Date()).format('YYYY-MM-DD')) + context.commit("update_default_mou", {}) + context.commit("update_default_doctor", {}) + context.commit("update_dialog_success", true) + if(context.state.act === 'new') + var msg = "Pembuatan setup nomor " + resp.data.records.xnumber + " sudah berhasil dong ..." + else + var msg = "Perubahan setup nomor " + resp.data.records.xnumber + " sudah berhasil dong ..." + + context.commit("update_msg_success", msg) + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async searchcity(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.searchcity(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_cities", resp.data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + } + }, + async searchdoctor(context,prm) { + context.commit("update_autocomplete_status",1) + try { + var xpar = {} + xpar.search = prm + xpar.token = one_token() + let resp= await api.searchdoctor(xpar) + if (resp.status != "OK") { + context.commit("update_autocomplete_status",3) + } else { + context.commit("update_autocomplete_status",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + var arr = resp.data.records + var xsel = context.state.selected_doctors + var filtered = arr.filter(o1 => xsel.filter(o2 => o2.id === o1.id).length === 0) + context.commit("update_doctors",filtered) + } + } catch(e) { + context.commit("update_autocomplete_status",3) + } + }, + async searchcompany(context,prm) { + context.commit("update_autocomplete_status",1) + try { + prm.token = one_token() + + let resp= await api.searchcompany(prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status",3) + } else { + context.commit("update_autocomplete_status",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_companies",resp.data.records) + } + } catch(e) { + context.commit("update_autocomplete_status",3) + } + }, + async getdistrict(context, prm) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.getdistrict(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + } else { + context.commit("update_get_data_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_districts", resp.data.records) + } + } catch (e) { + context.commit("update_get_data_status", 3) + } + }, + async getkelurahan(context, prm) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.getkelurahan(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + } else { + context.commit("update_get_data_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_kelurahans", resp.data.records) + } + } catch (e) { + context.commit("update_get_data_status", 3) + } + }, + async savenewaddress(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.savenewaddress(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + context.commit("update_dialog_form_address", false) + context.commit("update_last_id", prm.M_PatientAddressM_PatientID) + context.commit("update_dialog_success", true) + var msg = "Penambahan data alamat pasien " + prm.M_PatientName + " sudah berhasil dong ..." + context.commit("update_msg_success", msg) + + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async saveeditaddress(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.saveeditaddress(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + context.commit("update_dialog_form_address", false) + context.commit("update_last_id", prm.M_PatientAddressM_PatientID) + context.commit("update_dialog_success", true) + var msg = "Perubahan data alamat pasien " + prm.M_PatientName + " sudah berhasil dong ..." + context.commit("update_msg_success", msg) + + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async deleteaddress(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteaddress(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + context.commit("update_dialog_confirmation_delete_addr", false) + context.commit("update_last_id", prm.M_PatientAddressM_PatientID) + context.commit("update_dialog_success", true) + var msg = "Penghapusan data alamat " + prm.M_PatientAddressNote + " dari pasien " + prm.M_PatientName + " sudah berhasil dong ..." + context.commit("update_msg_success", msg) + + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async getmou(context,prm) { + context.commit("update_lookup_order",1) + try { + prm.token = one_token() + let resp= await api.getmou(prm) + if (resp.status != "OK") { + context.commit("update_lookup_order",3) + } else { + context.commit("update_lookup_order",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_mous",resp.data.records) + context.commit("update_mou",{}) + context.commit("update_selected_mous",[]) + } + } catch(e) { + context.commit("update_lookup_order",3) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-beginning-balance/store.js b/test/vuex/acc-beginning-balance/store.js new file mode 100644 index 0000000..67dd03e --- /dev/null +++ b/test/vuex/acc-beginning-balance/store.js @@ -0,0 +1,29 @@ +// State +// data ... +// Mutations +// +// +// Actions +import patient from "./modules/patient.js"; +import system from "../../../apps/modules/system/system.js"; +import balance from "./modules/balance.js"; +export const store = new Vuex.Store({ + modules: { + // patient: patient, + balance: balance, + system: system + }, + state: { + tab_selected: 'pasien-dokter' + }, + mutations: { + change_tab(state, ntab) { + state.tab_selected = ntab + } + }, + actions: { + change_tab(context, ntab) { + context.commit('change_tab', ntab) + } + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-inventaris/api/po.js b/test/vuex/acc-one-approve-po-inventaris/api/po.js new file mode 100644 index 0000000..7b86af1 --- /dev/null +++ b/test/vuex/acc-one-approve-po-inventaris/api/po.js @@ -0,0 +1,293 @@ +const URL = "/one-api/mockup/purchase/order/PurchaseOrderInventaris/"; +const URLRO = "/one-api/mockup/receive-item-po/receiveitempo/"; + +export async function getSupplier(payload) { + try { + var response = await axios.post(URL + "getSupplier", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItemCategory(payload) { + try { + var response = await axios.post(URL + "getItemCategory", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getWarehouse(payload) { + try { + var response = await axios.post(URL + "getWarehouse", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItem(payload) { + try { + var response = await axios.post(URL + "getItem", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItemUpdate(payload) { + try { + var response = await axios.post(URL + "getItemUpdate", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function saveOrder(payload) { + try { + var response = await axios.post(URL + "saveOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function search(payload) { + try { + var response = await axios.post(URL + "search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function requestOrder(payload) { + try { + var response = await axios.post(URL + "requestOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteOrder(payload) { + try { + var response = await axios.post(URL + "deleteOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateOrder(payload) { + try { + var response = await axios.post(URL + "updateOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approvePOrder(payload) { + try { + var response = await axios.post(URL + "approvePOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function isValidMultipleWarehouse(payload) { + try { + var response = await axios.post(URL + "isValidMultipleWarehouse", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function generateItemPO(params) { + try { + var response = await axios.post(URLRO + "generateItemPo", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getApprovalLevel(params) { + try { + var response = await axios.post(URL + 'getApproveLevel', params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getDefaultSupplierPrice(payload) { + try { + var response = await axios.post(URL + "getDefaultSupplierPrice", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-inventaris/components/dialogView.vue b/test/vuex/acc-one-approve-po-inventaris/components/dialogView.vue new file mode 100644 index 0000000..9c015e1 --- /dev/null +++ b/test/vuex/acc-one-approve-po-inventaris/components/dialogView.vue @@ -0,0 +1,595 @@ + + + + + diff --git a/test/vuex/acc-one-approve-po-inventaris/components/po.vue b/test/vuex/acc-one-approve-po-inventaris/components/po.vue new file mode 100644 index 0000000..2951f22 --- /dev/null +++ b/test/vuex/acc-one-approve-po-inventaris/components/po.vue @@ -0,0 +1,713 @@ + + + + + diff --git a/test/vuex/acc-one-approve-po-inventaris/components/poForm.vue b/test/vuex/acc-one-approve-po-inventaris/components/poForm.vue new file mode 100644 index 0000000..c8e34e0 --- /dev/null +++ b/test/vuex/acc-one-approve-po-inventaris/components/poForm.vue @@ -0,0 +1,1796 @@ + + + + + diff --git a/test/vuex/acc-one-approve-po-inventaris/functions/functions.js b/test/vuex/acc-one-approve-po-inventaris/functions/functions.js new file mode 100644 index 0000000..d0c94cc --- /dev/null +++ b/test/vuex/acc-one-approve-po-inventaris/functions/functions.js @@ -0,0 +1,411 @@ +/** + * Utility functions for the ACC One Purchase Order application + */ + +// /** +// * Groups an array of objects by a specified key +// * @param {Array} array - The array of objects to group +// * @param {String} key - The key to group by +// * @returns {Object} - An object with keys representing the grouped values and arrays as values +// */ +// export const groupBy = (array, key) => { +// return array.reduce((result, item) => { +// const groupKey = item[key]; +// if (!result[groupKey]) { +// result[groupKey] = []; +// } +// result[groupKey].push(item); +// return result; +// }, {}); +// }; +/** + * Groups an array of objects by one or multiple keys + * @param {Array} array - The array of objects to group + * @param {Function|String|Array} key - The key(s) to group by. Can be a string, array of strings, or a function. + * @returns {Object} - An object with keys representing the grouped values and arrays as values + */ +export const groupBy = (array, key) => { + return array.reduce((result, item) => { + let groupKey; + + // Handle single key (string), multiple keys (array), or custom function + if (typeof key === 'function') { + groupKey = key(item); + } else if (Array.isArray(key)) { + groupKey = key.map(k => item[k]).join('_'); // Combine multiple keys with underscore + } else { + groupKey = item[key]; + } + + if (!result[groupKey]) { + result[groupKey] = []; + } + result[groupKey].push(item); + return result; + }, {}); +}; + +/** + * Groups purchase request data by M_ItemID + * Terjadi jika ada beberapa item yang sama, maka akan digabungkan berdasarkan M_ItemID dan PoItemUnitID + * @param {Array} purchaseRequestData - Array of purchase request objects + * @returns {Array} - Array of objects with M_ItemID, M_ItemCode, M_ItemDesc, unit information, converted PoQty, and Details array + */ +export const groupPurchaseRequestsByItemId = (purchaseRequestData) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']); + // console.log("grouped"); + // console.log(grouped); + + return Object.keys(grouped).map(itemId => { + const items = grouped[itemId]; + const firstItem = items[0]; + + /* Sebelum Kalkulasi Konversi Item di BE */ + // // Calculate total PoQty from all items + // const totalPoQty = calculateTotalQuantity(items, 'PoQty'); + // // Get the conversion factor from the first item + // const conversionFactor = Number(firstItem.DefaultPurchase.UnitConvertAmount) || 1; + // // Convert the total quantity and round up if it's a decimal + // const convertedPoQty = Math.ceil(convertUnits(totalPoQty, conversionFactor)); + + /* Sesudah Kalkulasi Konversi Item di BE getItem() */ + const totalPoQty = calculateTotalQuantity(items, 'PoQty') + // console.log("Total PoQty for itemId", itemId, " : ", totalPoQty); + + // get price real or default supplier price + const realPrice = Number(firstItem.RealPrice ?? firstItem.DefaultPurchase.SupplierPricePrice) || 0; + + // let price = 0; + + // calculagte price after discount + let priceAfterDiscount = realPrice; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + priceAfterDiscount = realPrice - (Number(firstItem.discount) * (realPrice / 100)); + } + if (firstItem.discountType === 'R') { + priceAfterDiscount = realPrice - Number(firstItem.discount); + } + + } else { + priceAfterDiscount = realPrice || 0; + } + + // Get the price from the first item + // const realPrice = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + + // Calculate the total (PoQty * priceAfterDiscount) + const total = totalPoQty * priceAfterDiscount; + + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + TotalPoQty: totalPoQty, + Price: priceAfterDiscount, + RealPrice: realPrice, + PriceAfterDiscount: priceAfterDiscount, + Total: total, + Details: items + }; + }); +}; + +/** + * Formats a number as currency (IDR) + * @param {Number} amount - The amount to format + * @returns {String} - Formatted currency string + */ +export const formatCurrency = (amount) => { + return new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }).format(amount); +}; + +/** + * Formats a date to a localized string + * @param {Date|String} date - The date to format + * @param {Object} options - Intl.DateTimeFormat options + * @returns {String} - Formatted date string + */ +export const formatDate = (date, options = { + year: 'numeric', + month: 'long', + day: 'numeric' +}) => { + if (!date) return ''; + const dateObj = typeof date === 'string' ? new Date(date) : date; + return new Intl.DateTimeFormat('id-ID', options).format(dateObj); +}; + +/** + * Calculates the total value of purchase requests + * @param {Array} items - Array of purchase request items + * @returns {Number} - Total value + */ +export const calculateTotal = (items) => { + return items.reduce((sum, item) => sum + (Number(item.Total) || 0), 0); +}; + +/** + * Calculates the total quantity of items + * @param {Array} items - Array of purchase request items + * @param {String} qtyField - The field name containing quantity (e.g., 'PoQty') + * @returns {Number} - Total quantity + */ +export const calculateTotalQuantity = (items, qtyField = 'PoQty') => { + // console.log("Items in calculateTotalQuantity:", items); + return items.reduce((sum, item) => sum + (Number(item[qtyField]) || 0), 0); +}; + +/** + * Converts units based on the conversion factor + * @param {Number} quantity - The quantity to convert + * @param {Number} conversionFactor - The conversion factor + * @returns {Number} - Converted quantity + */ +export const convertUnits = (quantity, conversionFactor) => { + return quantity / conversionFactor; +}; + +/** + * Filters purchase requests by branch + * @param {Array} items - Array of purchase request items + * @param {String|Array} branchCodes - Branch code(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByBranch = (items, branchCodes) => { + if (!branchCodes) return items; + + const codes = Array.isArray(branchCodes) ? branchCodes : [branchCodes]; + return items.filter(item => codes.includes(item.BranchCode)); +}; + +/** + * Filters purchase requests by regional + * @param {Array} items - Array of purchase request items + * @param {String|Array} regionalIds - Regional ID(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByRegional = (items, regionalIds) => { + if (!regionalIds) return items; + + const ids = Array.isArray(regionalIds) ? regionalIds : [regionalIds]; + return items.filter(item => ids.includes(item.S_RegionalID)); +}; + +/** + * Validates if a purchase request item has all required fields + * @param {Object} item - Purchase request item + * @returns {Boolean} - True if valid, false otherwise + */ +export const validatePurchaseRequestItem = (item) => { + const requiredFields = [ + 'M_ItemID', + 'M_ItemCode', + 'M_ItemDesc', + 'Price', + 'RequestQty' + ]; + + return requiredFields.every(field => item[field] !== undefined && item[field] !== null); +}; + +/** + * Sorts purchase request items by a specified field + * @param {Array} items - Array of purchase request items + * @param {String} field - Field to sort by + * @param {Boolean} ascending - Sort direction (true for ascending, false for descending) + * @returns {Array} - Sorted items + */ +export const sortPurchaseRequests = (items, field = 'M_ItemDesc', ascending = true) => { + return [...items].sort((a, b) => { + const valueA = a[field]; + const valueB = b[field]; + + if (typeof valueA === 'string' && typeof valueB === 'string') { + return ascending + ? valueA.localeCompare(valueB) + : valueB.localeCompare(valueA); + } + + return ascending + ? (valueA - valueB) + : (valueB - valueA); + }); +}; + +/** + * Validates purchase order data before saving + * @param {Object} context - Vuex context object + * @returns {Boolean} - Returns true if validation passes, false otherwise + */ +export const validatePurchaseOrder = (context) => { + if (context.state.loading) { + let snackbar = { + state: true, + type: "warning", + message: 'Loading sedang berlangsung harap menunggu ...', + }; + context.commit("update_snackbar", snackbar); + return false; + } + + let warningMsg = []; + if (context.state.selectedItem.length == 0) { + warningMsg.push('Belum memilih item'); + } + if (!context.state.refNumber || context.state.refNumber.trim() === '') { + warningMsg.push('Nomor Referensi belum diisi'); + } + if (!context.state.selectedWarehouse || !context.state.selectedWarehouse.WarehouseID && context.state.warehouseType !== 'Multiple') { + warningMsg.push('Tipe Gudang Single Harus memilih Gudang'); + } + if (!context.state.selectedSupplier || !context.state.selectedSupplier.SupplierID) { + warningMsg.push('Supplier belum dipilih'); + } + if (context.state.discountType === 'Percentage') { + const discountValue = (context.state.itemTotal.total * context.state.discountAmount) / 100; + if (discountValue > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } else if (context.state.discountType === 'Absolute') { + if (context.state.discountAmount > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } + + context.state.summary.forEach(element => { + if (Number(element.discount) < 0) { + warningMsg.push('Diskon ' + element.M_ItemDesc + ' tidak boleh kurang dari 0'); + } + if (element.discountType === 'P') { + if (Number(element.discount) > 100) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi 100'); + } + } + if (element.discountType === 'R') { + if (Number(element.discount) > Number(element.RealPrice)) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi dari harga'); + } + } + }); + + if (warningMsg.length > 0) { + let snackbar = { + state: true, + type: "warning", + message: warningMsg.join(", "), + }; + context.commit("update_snackbar", snackbar); + return false; + } + + return true; +}; + +/** + * Menghitung total summary untuk purchase order + * @param {Array} summary - Array data summary + * @param {Number} taxPpn - Persentase pajak PPN + * @param {Number} taxPph - Persentase pajak PPH + * @param {String} discountType - Tipe diskon ('Percentage' atau 'Absolute') + * @param {Number} discountAmount - Jumlah diskon + * @returns {Object} - Object summaryTotal + */ +export const calculateSummaryTotal = (summary, typePpnSelected = 'Percentage', taxPpn = 0, taxPph = 0, discountType = 'Percentage', discountAmount = 0) => { + if (!summary || summary.length === 0) { + return { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }; + } + + // Hitung total dari item summary + const total = summary.reduce((acc, item) => acc + (Number(item.Total) || 0), 0); + + // Hitung diskon berdasarkan tipe + let discount = discountAmount; + if (discountType === 'Percentage') { + discount = (discountAmount / 100) * total; + } + + // Hitung pajak + const newTotal = total - discount; + let ppn = taxPpn; + if (typePpnSelected === 'Percentage' && taxPpn > 0) { + ppn = (taxPpn / 100) * newTotal; + } + const pph = (taxPph / 100) * newTotal; + const tax = ppn + pph; + const finalTotal = newTotal + tax; + + // Return object summaryTotal + return { + total: total, + tax: tax, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: finalTotal, + }; +}; + + +/** + * Menghapus item dari summary dan selectedItem berdasarkan itemId atau detailId + * @param {Array} summary - Array data summary + * @param {Array} selectedItem - Array data selectedItem + * @param {String} itemId - ID item yang akan dihapus (opsional) + * @param {String} detailId - ID detail yang akan dihapus (opsional) + * @returns {Object} - Object berisi summary dan selectedItem yang sudah diupdate + */ +export const deleteItemFromSummary = (summary, selectedItem, itemId = null, detailId = null) => { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = summary.filter(item => item.M_ItemID !== itemId); + const newSelectedItem = selectedItem.filter(item => item.M_ItemID !== itemId); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = selectedItem.filter(item => item.PurchaseRequestFlagID !== detailId); + + // Regenerate summary dari selectedItem yang baru + const newSummary = groupPurchaseRequestsByItemId(newSelectedItem); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + return { + summary, + selectedItem + }; +}; \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-inventaris/index.php b/test/vuex/acc-one-approve-po-inventaris/index.php new file mode 100644 index 0000000..d3024d3 --- /dev/null +++ b/test/vuex/acc-one-approve-po-inventaris/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-inventaris/modules/po.js b/test/vuex/acc-one-approve-po-inventaris/modules/po.js new file mode 100644 index 0000000..c73507b --- /dev/null +++ b/test/vuex/acc-one-approve-po-inventaris/modules/po.js @@ -0,0 +1,1474 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/po.js"; +import { validatePurchaseOrder, groupPurchaseRequestsByItemId, calculateSummaryTotal } from "../functions/functions.js"; + +export default { + namespaced: true, + state: { + statusOptions: [ + { value: 'All', title: "All" }, + { value: 'Draft', title: "Draft" }, + { value: 'Pending', title: "Pending" }, + { value: 'Approved', title: "Approved" }, + { value: 'Rejected', title: "Rejected" }, + { value: 'Completed', title: "Completed" }, + ], + selectedStatus: { value: 'All', title: "All" }, + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + search: '', + totalPage: 0, + selectedPage: 1, + loading: false, + poList: [ + { + "poNumber": "PO1234566", + "poDate": "01-01-2025", + "poVendor": "PT ABC 123", + "poTotal": "1000000", + "poStatus": "DRAFT", + } + ], + dialogForm: false, + detailData: [], + selectedPr: {}, + loadingDetail: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + //FORM + selectedDateForm: moment(new Date()).format('YYYY-MM-DD'), + selectedDateEnd: moment(new Date()).format('YYYY-MM-DD'), + selectedSupplier: {}, + refNumber: '', + taxPpn: 0, + taxPph: 0, + paymentTerm: 0, + discountType: 'Percentage', + discountTypeList: ['Percentage', 'Absolute'], + discountAmount: 0, + note: '', + warehouseTypeList: ['Single', 'Multiple'], + warehouseType: 'Single', + warehouseList: [], + selectedWarehouse: {}, + itemList: [], + selectedItemTemp: [], + selectedItem: [], + searchItem: '', + itemTotal: { + total: 0, + ppn: 0, + pph: 0, + tax: 0, + discount: 0, + finalTotal: 0, + }, + defaultWarehouse: {}, + shippingCost: 0, + shippingCostStatus: true,//Sudah di bayar atau belum + //END FORM + supplierList: [], + loadingAutocomplete: false, + searchSupplier: "", + dialogConfirmation: false, + dialogDelete: false, + selectedPO: {}, + dialogItem: false, + currentPageItem: 1, + totalPageItem: 0, + dialogFormAct: 'ADD', + summary: [], + summaryTotal: { + total: 0, + ppn: 0, + pph: 0, + tax: 0, + discount: 0, + finalTotal: 0, + }, + deletedItem: [],//kalau edit item sebelumnya yang dihapus masuk sini agar bisa dipilih lagi , + dialogView: false, + itemCategoryList: [], + selectedItemCategory: {}, + open_print: false, + // isValidMultipleWarehouse: false, // Flag untuk validasi multiple warehouse + isValidMultipleWarehouse: { + status: false, + message: '', + }, + approve_level: 0, + status: '', + xstartdate: '', + itemDesc: '', + flag: '', + typePpn: ['Percentage', 'Absolute'], + typePpnSelected: 'Percentage', + }, + mutations: { + update_shippingCost(state, val) { + state.shippingCost = val; + }, + update_shippingCostStatus(state, val) { + state.shippingCostStatus = val; + }, + update_selectedItemCategory(state, val) { + state.selectedItemCategory = val; + }, + update_itemCategoryList(state, val) { + state.itemCategoryList = val; + }, + update_dialogView(state, val) { + state.dialogView = val; + }, + update_deletedItem(state, val) { + state.deletedItem = val; + }, + update_summaryTotal(state, val) { + state.summaryTotal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialogFormAct(state, val) { + state.dialogFormAct = val; + }, + update_totalPageItem(state, val) { + state.totalPageItem = val; + }, + update_currentPageItem(state, val) { + state.currentPageItem = val; + }, + update_dialogItem(state, val) { + state.dialogItem = val; + }, + update_selectedPO(state, val) { + state.selectedPO = val; + }, + update_dialogDelete(state, val) { + state.dialogDelete = val; + }, + update_dialogConfirmation(state, val) { + state.dialogConfirmation = val; + }, + update_defaultWarehouse(state, val) { + state.defaultWarehouse = val; + }, + update_itemTotal(state, val) { + state.itemTotal = val; + }, + update_searchItem(state, val) { + state.searchItem = val; + }, + update_selectedItemTemp(state, val) { + state.selectedItemTemp = val; + }, + update_selectedItem(state, val) { + state.selectedItem = val; + }, + update_itemList(state, val) { + state.itemList = val; + }, + update_warehouseList(state, val) { + state.warehouseList = val; + }, + update_supplierList(state, val) { + state.supplierList = val; + }, + update_searchSupplier(state, val) { + state.searchSupplier = val; + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + update_selectedWarehouse(state, val) { + state.selectedWarehouse = val; + }, + update_warehouseTypeList(state, val) { + state.warehouseTypeList = val; + }, + update_warehouseType(state, val) { + state.warehouseType = val; + // Disable and clear selectedWarehouse when type is Multiple + if (val === 'Multiple') { + state.selectedWarehouse = {}; + } + }, + update_note(state, val) { + state.note = val; + }, + update_discountAmount(state, val) { + // debugger; + if (state.discountType === 'Percentage' && val > 100) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Diskon tidak boleh lebih dari 100', + }; + state.discountAmount = 100; + return; + } + if (state.discountType === 'Absolute' && val > state.itemTotal.total && state.itemTotal.total > 0) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Diskon tidak boleh lebih dari total', + }; + state.discountAmount = state.itemTotal.total; + return; + } + state.discountAmount = val; + }, + update_discountType(state, val) { + state.discountType = val; + }, + update_paymentTerm(state, val) { + state.paymentTerm = val; + }, + update_taxPpn(state, val) { + if (state.typePpnSelected === 'Percentage' && val > 100) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Persen tidak boleh lebih dari 100', + }; + state.taxPpn = 100; + return; + } + if (state.typePpnSelected === 'Absolute' && val > state.itemTotal.total && state.itemTotal.total > 0) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Ppn tidak boleh lebih dari total', + }; + state.taxPpn = state.itemTotal.total; + return; + } + state.taxPpn = val; + // if (val > 0) { + // state.taxPpn = val; + // } else { + // state.taxPpn = 0; + // } + }, + update_taxPph(state, val) { + if (val > 0) { + state.taxPph = val; + } else { + state.taxPph = 0; + } + }, + update_refNumber(state, val) { + state.refNumber = val; + }, + update_selectedSupplier(state, val) { + state.selectedSupplier = val; + }, + update_selectedDateForm(state, val) { + state.selectedDateForm = val; + }, + update_selectedDateEnd(state, val) { + state.selectedDateEnd = val; + }, + update_snackbar(state, val) { + state.snackbar = val; + }, + update_loadingDetail(state, val) { + state.loadingDetail = val; + }, + update_selectedPr(state, val) { + state.selectedPr = val; + }, + update_detailData(state, val) { + state.detailData = val; + }, + update_dialogForm(state, val) { + state.dialogForm = val; + }, + update_selectedStatus(state, val) { + state.selectedStatus = val; + }, + update_selectedDate(state, val) { + state.selectedDate = val; + }, + update_search(state, val) { + state.search = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_totalPage(state, val) { + state.totalPage = val; + }, + update_selectedPage(state, val) { + state.selectedPage = val; + }, + update_poList(state, val) { + state.poList = val; + }, + update_open_print(state, value) { + state.open_print = value + }, + update_isValidMultipleWarehouse(state, value) { + state.isValidMultipleWarehouse = value; + }, + update_approve_level(state, data) { + state.approve_level = data + }, + update_status(state, val) { + state.status = val + }, + update_xstartdate(state, val) { + state.xstartdate = val + }, + update_itemDesc(state, val) { + state.itemDesc = val; + }, + update_flag(state, val) { + state.flag = val + }, + update_typePpn(state, val) { + state.typePpn = val; + }, + update_typePpnSelected(state, val) { + state.typePpnSelected = val; + }, + }, + actions: { + async deleteItemFromSummary(context, { itemId = null, detailId = null }) { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = context.state.summary.filter(item => item.keyID !== itemId); + const newSelectedItem = context.state.selectedItem.filter(item => item.keyID !== itemId); + if (context.state.dialogFormAct === 'EDIT') { + let deletedItemBefore = JSON.parse(JSON.stringify(context.state.deletedItem)) + const deletedItem = context.state.selectedItem.filter(item => item.keyID === itemId + && item.PurchaseOrderDetailID !== undefined + && item.PurchaseOrderDetailID !== null + && item.PurchaseOrderDetailID !== 0); + let newDeletedItem = [] + deletedItem.forEach(de => { + let cek = deletedItemBefore.find((element) => + element.M_ItemID === de.M_ItemID + && element.PurchaseRequestFlagID === de.PurchaseRequestFlagID + && element.PurchaseOrderDetailID === de.PurchaseOrderDetailID) + if (!cek) { + newDeletedItem.push(de) + } + }); + context.commit('update_deletedItem', [...deletedItemBefore, ...newDeletedItem]); + } + context.commit('update_summary', newSummary); + context.commit('update_selectedItem', newSelectedItem); + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = context.state.selectedItem.filter( + item => item.PurchaseRequestFlagID !== detailId + ); + if (context.state.dialogFormAct === 'EDIT') { + let deletedItemBefore = JSON.parse(JSON.stringify(context.state.deletedItem)) + const deletedItem = context.state.selectedItem.filter( + item => item.PurchaseRequestFlagID === detailId + && item.PurchaseOrderDetailID !== undefined + && item.PurchaseOrderDetailID !== null + && item.PurchaseOrderDetailID !== 0 + ); + let newDeletedItem = [] + deletedItem.forEach(de => { + let cek = deletedItemBefore.find((element) => + element.M_ItemID === de.M_ItemID + && element.PurchaseRequestFlagID === de.PurchaseRequestFlagID + && element.PurchaseOrderDetailID === de.PurchaseOrderDetailID) + if (!cek) { + newDeletedItem.push(de) + } + }); + context.commit('update_deletedItem', [...deletedItemBefore, ...newDeletedItem]); + } + + // Regenerate summary dari selectedItem yang baru + const newSummary = await groupPurchaseRequestsByItemId(newSelectedItem, context); + + context.commit('update_summary', newSummary); + context.commit('update_selectedItem', newSelectedItem); + } + + // Hitung ulang total + context.dispatch('countItemTotal'); + context.dispatch('generateSummary'); + }, + + generateSummaryTotal(context) { + const summaryTotal = calculateSummaryTotal( + context.state.summary, + context.state.typePpnSelected, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + context.commit('update_summaryTotal', summaryTotal); + }, + + async generateSummary(context) { + let data = JSON.parse(JSON.stringify(context.state.selectedItem)); + console.log("Data untuk param groupPurchaseRequestsByItemId:", JSON.parse(JSON.stringify(data))); + + /** + * Tambah validasi: + * > Apakah bisa multiple warehouse? + */ + context.dispatch('isValidMultipleWarehouse'); + + if (context.state.warehouseType === "Multiple") { + data.forEach((element) => { + element.warehouse = { + WarehouseID: element.WarehouseID, + WarehouseName: element.WarehouseName, + }; + }); + } else if (context.state.warehouseType === "Single") { + data.forEach((element) => { + element.warehouse = context.state.selectedWarehouse; // Semua item pakai warehouse yang sama + }); + } + + let summary = await groupPurchaseRequestsByItemId(data, context); + context.commit('update_summary', summary); + console.log("Summary setelah grouping:", JSON.parse(JSON.stringify(summary))); + + // Hitung summary total menggunakan fungsi dari functions.js + const summaryTotal = calculateSummaryTotal( + summary, + context.state.typePpnSelected, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + }, + + multipleWarehouseValidation(context, selectedItem) { + let data; + + if (!selectedItem || selectedItem.length === 0) { + data = JSON.parse(JSON.stringify(context.state.selectedItem)); + } else { + data = JSON.parse(JSON.stringify(selectedItem)); + } + + // Pakai 'Set' JS Object yang hanya menyimpan nilai unik. + const warehouseIds = new Set(); + + data.forEach(item => { + if (item.WarehouseID) { + // Kalau ada yang sama maka disimpan sekali. + warehouseIds.add(item.WarehouseID); + } + }); + + if (warehouseIds.size > 1) { + return true; // Ada lebih dari satu WarehouseID + } else { + return false; // Hanya ada satu WarehouseID + } + }, + + async isValidMultipleWarehouse(context) { + /** + * @param: array of PurchaseRequestDetailID dari selectedItem + * @api: api.isValidMultipleWarehouse + * @return: JSON -> {data.status (boolean), data.message (string)} + * + */ + if (context.state.selectedItem.length === 0) { + return false; // Tidak ada item yang dipilih + } + try { + let payload = { + "PurchaseRequestDetailIDs": context.state.selectedItem.map(item => item.PurchaseRequestDetailID), + "token": one_token(), + }; + + let response = await api.isValidMultipleWarehouse(payload) + + console.log("Payload untuk isValidMultipleWarehouse:", JSON.parse(JSON.stringify(payload.PurchaseRequestDetailIDs))); + console.log("Response dari isValidMultipleWarehouse:", JSON.parse(JSON.stringify(response))); + + if (response.status !== "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_isValidMultipleWarehouse", { + status: false, + message: '', + }); + context.commit("update_snackbar", snackbar); + } else {; + context.commit("update_isValidMultipleWarehouse", { + status: response.data.status, + message: response.data.message, + }); + if(response.data.status == false) { + context.commit("update_warehouseType", 'Single'); + context.commit("update_selectedWarehouse", context.state.selectedWarehouse); + } + }; + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + } + }, + + assignEdit(context) { + let data = context.state.selectedPO + context.commit("update_selectedDateForm", data.PurchaseOrderDate); + context.commit("update_searchSupplier", data.SupplierName); + context.commit("update_selectedSupplier", { + "SupplierID": data.PurchaseOrderSupplierID, + "SupplierCode": data.SupplierCode, + "SupplierName": data.SupplierName + }); + context.commit("update_selectedItemCategory", { + "itemCategoryID": data.itemCategoryID, + "itemCategoryName": data.itemCategoryName + }); + context.commit("update_refNumber", data.PurchaseOrderRefNumber); + context.commit("update_shippingCost", data.PurchaseOrderShippingCost); + context.commit("update_shippingCostStatus", data.PurchaseOrderShippingCostStatus === 'Y' ? true : false); + context.commit("update_typePpnSelected", data.PurchaseOrderTaxPercentPpn > 0 ? 'Percentage' : 'Absolute'); + if (data.PurchaseOrderTaxPercentPpn > 0) { + context.commit("update_taxPpn", parseFloat(data.PurchaseOrderTaxPercentPpn)); + } else { + context.commit("update_taxPpn", parseFloat(data.PurchaseOrderTaxAmountPpn)); + } + context.commit("update_taxPph", data.PurchaseOrderTaxPercentPph); + context.commit("update_paymentTerm", data.PurchaseOrderPaymentTerm); + context.commit("update_discountType", data.PurchaseOrderDiscountPercent > 0 ? 'Percentage' : 'Absolute'); + if (data.PurchaseOrderDiscountPercent > 0) { + context.commit("update_discountAmount", parseFloat(data.PurchaseOrderDiscountPercent)); + } else { + context.commit("update_discountAmount", parseFloat(data.PurchaseOrderDiscountAmount)); + } + context.commit("update_note", data.PurchaseOrderNote); + context.commit("update_warehouseType", data.PurchaseOrderWarehouseType); + context.commit("update_selectedWarehouse", { + "WarehouseID": data.PurchaseOrderWarehouseID, + "WarehouseCode": data.WarehouseCode, + "WarehouseName": data.WarehouseName, + }); + context.commit("update_dialogFormAct", 'EDIT'); + context.dispatch("countItemTotal"); + }, + + resetForm(context) { + context.commit("update_selectedDateForm", moment(new Date()).format('YYYY-MM-DD')); + context.commit("update_selectedSupplier", {}); + context.commit("update_refNumber", ''); + context.commit("update_taxPpn", 0); + context.commit("update_typePpnSelected", 'Percentage'); + context.commit("update_taxPph", 0); + context.commit("update_paymentTerm", 0); + context.commit("update_discountType", 'Percentage'); + context.commit("update_discountAmount", 0); + context.commit("update_note", ''); + context.commit("update_warehouseType", 'Single'); + context.commit("update_selectedWarehouse", context.state.defaultWarehouse); + context.commit("update_itemList", []); + context.commit("update_selectedItemTemp", []); + context.commit("update_selectedItem", []); + context.commit("update_deletedItem", []); + context.commit("update_selectedItemCategory", {}); + context.commit("update_summary", []); + context.commit("update_searchItem", ''); + context.commit("update_shippingCost", 0); + context.commit("update_shippingCostStatus", true); + context.commit("update_dialogFormAct", 'ADD'); + context.commit("update_summaryTotal", { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }); + context.commit("update_itemTotal", { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }); + }, + + countItemTotal(context) { + let selectedItem = context.state.selectedItem; + if (selectedItem.length === 0) { + let hasil = { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + } + context.commit("update_itemTotal", hasil); + return; + } + + // Fix: Ensure we're working with numeric values + let total = selectedItem.reduce((acc, item) => { + // Convert string to number if needed + const itemTotal = typeof item.Total === 'string' ? + parseFloat(item.Total.replace(/\./g, '').replace(',', '.')) : + item.Total; + return acc + (isNaN(itemTotal) ? 0 : itemTotal); + }, 0); + + total = Math.round(total * 100) / 100; + + let discount = parseFloat(context.state.discountAmount) || 0; + if (context.state.discountType === 'Percentage') { + discount = Math.round((discount / 100) * total * 100) / 100; + } + + let newTotal = Math.round((total - discount) * 100) / 100; + + let ppn = 0; + if (context.state.typePpnSelected === 'Absolute') { + ppn = context.state.taxPpn; + } else { + ppn = Math.round((parseFloat(context.state.taxPpn) / 100) * newTotal * 100) / 100; + } + + let pph = Math.round((parseFloat(context.state.taxPph) / 100) * newTotal * 100) / 100; + let pajak = Math.round((ppn + pph) * 100) / 100; + let final = Math.round((newTotal + pajak) * 100) / 100; + + let hasil = { + total: total, + tax: pajak, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: final, + } + context.commit("update_itemTotal", hasil); + }, + + updatePoQty(context, { itemId, newPoQty }) { + let updatedSelectedItem = context.state.selectedItem.map(item => { + if (item.PurchaseRequestFlagID === itemId) { + // Convert string to number and ensure minimum value of 1 + const numericPoQty = Number(newPoQty); + item.PoQty = Math.max(1, Math.floor(isNaN(numericPoQty) ? 1 : numericPoQty)); + + // Recalculate item total + let price = item.DefaultPurchase?.SupplierPricePrice || 0; + + // Apply discount if exists + if (item.discount > 0) { + if (item.discountType === 'P') { + price = price - (item.discount * price / 100); + } else if (item.discountType === 'R') { + price = price - item.discount; + } + } + + item.Total = item.PoQty * price; + } + return item; + }); + + context.commit('update_selectedItem', updatedSelectedItem); + + // Regenerate summary + context.dispatch('generateSummary'); + context.dispatch('countItemTotal'); + context.dispatch('generateSummaryTotal'); + }, + + async getSupplier(context) { + if (context.state.searchSupplier.length < 2) return; + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + token: one_token(), + search: context.state.searchSupplier, + + }; + + let response = await api.getSupplier(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_supplierList", data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getItemCategory(context) { + + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + token: one_token(), + + }; + + let response = await api.getItemCategory(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_itemCategoryList", data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getWarehouse(context) { + + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + regionalId: one_user().S_RegionalID, + token: one_token(), + }; + + let response = await api.getWarehouse(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + response.data.records.forEach(element => { + if (element.WarehouseIsDefault === 'Y') { + context.commit("update_defaultWarehouse", element); + } + + }); + context.commit("update_warehouseList", response.data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getItem(context) { + context.commit("update_loading", true); + try { + var payload = { + "search": context.state.searchItem, + "currentPage": context.state.currentPageItem, + "supplierID": context.state.selectedSupplier.SupplierID, + "itemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "regionalId": one_user().S_RegionalID, + "token": one_token(), + }; + + let response = await api.getItem(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_itemList", data.records); + context.commit("update_totalPageItem", data.total); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getItemUpdate(context) { + context.commit("update_loading", true); + try { + var payload = { + "POID": context.state.selectedPO.PurchaseOrderID, + "token": one_token(), + }; + + let response = await api.getItemUpdate(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_selectedItem", data.records); + /** + * Tambah validasi: + * > Apakah bisa multiple warehouse? + */ + context.dispatch('isValidMultipleWarehouse'); + + context.commit("update_summary", response.data.summary) + context.dispatch("countItemTotal"); + // Hitung summary total menggunakan fungsi dari functions.js + // TODO: Check ini akibat penyesuaian + const summaryTotal = calculateSummaryTotal( + response.data.summary, + context.state.typePpnSelected, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async saveOrder(context) { + try { + if (!validatePurchaseOrder(context)) { + return; + } + + const invalidQtyItems = context.state.selectedItem.filter(item => { + // Convert string to number first + const poQty = Number(item.PoQty); + + // Check if conversion failed (NaN), is less than 1, or not an integer + return isNaN(poQty) || poQty < 1 || !Number.isInteger(poQty); + }); + + if (invalidQtyItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki quantity minimal 1", + } + context.commit("update_snackbar", snackbar); + return; + } + + context.commit("update_loading", true); + + // menambahkan pengecekan tax ppn 19-12-2025 + // jika ppn persen maka masuk ke tax persentppn + // jika ppn absolute maka masuk ke tax amount ppn + let ppnPercent = 0; + if (context.state.typePpnSelected === 'Percentage') { + ppnPercent = context.state.taxPpn; + } + + var payload = { + "token": one_token(), + "Date": context.state.selectedDateForm, + "RefNumber": context.state.refNumber, + "SupplierID": context.state.selectedSupplier.SupplierID, + "ItemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "TaxPpnType": context.state.typePpnSelected === 'Percentage' ? 'P' : 'R', + "TaxPercent": ppnPercent, + "PaymentTerm": context.state.paymentTerm, + "DiscountPercent": context.state.discountType === 'Percentage' ? context.state.discountAmount : 0, + "DiscountAmount": context.state.discountType === 'Absolute' ? context.state.discountAmount : 0, + "WarehouseType": context.state.warehouseType, + "WarehouseID": context.state.selectedWarehouse.WarehouseID, + "Note": context.state.note, + "SubTotal": context.state.summaryTotal.total, + "TaxPercentPph": context.state.taxPph, + "TaxPercentPpn": ppnPercent, + "TaxAmount": context.state.summaryTotal.tax, + "TaxAmountPph": context.state.summaryTotal.pph, + "TaxAmountPpn": context.state.summaryTotal.ppn, + "GrandTotal": context.state.summaryTotal.finalTotal, + "ShippingCost": context.state.shippingCost, + "ShippingCostStatus": context.state.shippingCostStatus, + // "Details": detail, + "Summary": context.state.summary + }; + + // Validasi Total Tidak Boleh <0 + const financialChecks = [ + { value: payload.GrandTotal, name: "Total" }, + { value: payload.SubTotal, name: "Sub Total" }, + { value: payload.TaxAmount, name: "Pajak" }, + { value: payload.TaxAmountPph, name: "Pajak PPH" }, + { value: payload.TaxAmountPpn, name: "Pajak PPN" }, + { value: payload.DiscountAmount, name: "Diskon" }, + { value: payload.ShippingCost, name: "Biaya Ekspedisi" } + ]; + + for (const check of financialChecks) { + if (check.value < 0) { + let snackbar = { + state: true, + type: "error", + message: `${check.name} tidak boleh kurang dari 0`, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + return; + } + } + + let response = await api.saveOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil simpan data", + } + context.commit("update_snackbar", snackbar); + + + context.commit("update_loading", false); + context.commit("update_dialogForm", false); + context.dispatch("resetForm"); + context.dispatch("searchData"); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async searchData(context) { + context.commit("update_loading", true); + try { + + var url_string = window.location.href + var url = new URL(url_string); + var status = url.searchParams.get("status"); + var xstartdate = url.searchParams.get("startdate"); + var xsearch = url.searchParams.get("search"); + var xflag = url.searchParams.get("flag"); + + // untuk notifikasi + if (xflag == 'N') { + + if (xsearch != null && xsearch != '') { + context.commit("update_search", xsearch); + } + if (status != null && status != '') { + context.commit("update_selectedStatus", { value: status, title: status }); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedEndDate", xstartdate); + } + + } else if (xflag == 'G') { + // untuk get data param approve all + + if (status != null && status != '') { + context.commit("update_selectedStatus", { value: status, title: status }); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedDateEnd", moment(new Date()).format('YYYY-MM-DD')); + } + context.commit("update_flag", xflag); + + } + + var payload = { + "token": one_token(), + "currentPage": context.state.selectedPage, + "search": context.state.search, + "startDate": context.state.selectedDate, + "endDate": context.state.selectedDateEnd, + "status": context.state.selectedStatus.value, + "flag": context.state.flag + }; + + let response = await api.search(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("update_totalPage", response.data.totalPage); + context.commit("update_poList", data.records); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async requestOrder(context) { + context.commit("update_loading", true); + + try { + + var payload = { + "token": one_token(), + "ID": context.state.selectedPO.PurchaseOrderID, + }; + + let response = await api.requestOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil request order", + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + context.commit("update_dialogConfirmation", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async deleteOrder(context) { + context.commit("update_loading", true); + + try { + var payload = { + "token": one_token(), + "PurchaseOrderId": context.state.selectedPO.PurchaseOrderID, + }; + + let response = await api.deleteOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil hapus order", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + context.commit("update_dialogDelete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async updateOrder(context) { + try { + if (!validatePurchaseOrder(context)) { + return; + } + + const invalidQtyItems = context.state.selectedItem.filter(item => { + // Convert string to number first + const poQty = Number(item.PoQty); + + // Check if conversion failed (NaN), is less than 1, or not an integer + return isNaN(poQty) || poQty < 1 || !Number.isInteger(poQty); + }); + + console.log("InvalidQtyItem updateOrder", invalidQtyItems) + + if (invalidQtyItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki quantity minimal 1", + } + context.commit("update_snackbar", snackbar); + return; + } + + // menambahkan pengecekan tax ppn 19-12-2025 + // jika ppn persen maka masuk ke tax persentppn + // jika ppn absolute maka masuk ke tax amount ppn + let ppnPercent = 0; + if (context.state.typePpnSelected === 'Percentage') { + ppnPercent = context.state.taxPpn; + } + + var payload = { + "token": one_token(), + "Date": context.state.selectedDateForm, + "RefNumber": context.state.refNumber, + "SupplierID": context.state.selectedSupplier.SupplierID, + "TaxPpnType": context.state.typePpnSelected === 'Percentage' ? 'P' : 'R', + "TaxPercent": ppnPercent, + "PaymentTerm": context.state.paymentTerm, + "ItemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "DiscountPercent": context.state.discountType === 'Percentage' ? context.state.discountAmount : 0, + "DiscountAmount": context.state.discountType === 'Absolute' ? context.state.discountAmount : 0, + "WarehouseType": context.state.warehouseType, + "WarehouseID": context.state.selectedWarehouse.WarehouseID, + "Note": context.state.note, + "SubTotal": context.state.summaryTotal.total, + "TaxPercentPph": context.state.taxPph, + "TaxPercentPpn": ppnPercent, + "TaxAmount": context.state.summaryTotal.tax, + "TaxAmountPph": context.state.summaryTotal.pph, + "TaxAmountPpn": context.state.summaryTotal.ppn, + "GrandTotal": context.state.summaryTotal.finalTotal, + "ShippingCost": context.state.shippingCost, + "ShippingCostStatus": context.state.shippingCostStatus, + "PO": context.state.selectedPO, + "Summary": context.state.summary, + "deletedItem": context.state.deletedItem, + "IsApprovalEdit": true, + }; + + // Validasi Total Tidak Boleh <0 + const financialChecks = [ + { value: payload.GrandTotal, name: "Total" }, + { value: payload.SubTotal, name: "Sub Total" }, + { value: payload.TaxAmount, name: "Pajak" }, + { value: payload.TaxAmountPph, name: "Pajak PPH" }, + { value: payload.TaxAmountPpn, name: "Pajak PPN" }, + { value: payload.DiscountAmount, name: "Diskon" }, + { value: payload.ShippingCost, name: "Biaya Ekspedisi" } + ]; + + for (const check of financialChecks) { + if (check.value < 0) { + let snackbar = { + state: true, + type: "error", + message: `${check.name} tidak boleh kurang dari 0`, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + return; + } + } + + context.commit("update_loading", true); + let response = await api.updateOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil simpan data", + } + context.commit("update_snackbar", snackbar); + + + context.commit("update_loading", false); + context.commit("update_dialogForm", false); + context.dispatch("resetForm"); + context.dispatch("searchData"); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async approveOrder(context, payload) { + context.commit("update_loading", true); + try { + payload.token = one_token() + payload.approvelevel = context.state.approve_level + + let response = await api.approvePOrder(payload); + if (response.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + if (context.state.approve_level == '2') { + let params = { token: one_token(), id: payload.poID } + let generateitempo = await api.generateItemPO(params) + if (generateitempo.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let snackbar = { + state: true, + type: "success", + message: "Berhasil approve order", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + } + } else { + let snackbar = { + state: true, + type: "success", + message: "Berhasil approve order manager", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + } + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getApprovalLevel(context) { + context.commit("update_loading", true); + try { + let response = await api.getApprovalLevel({token: one_token()}); + if (response.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = response.data.M_UserM_ApproveLevelID + + context.commit("update_approve_level", data) + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getDefaultSupplierPrice(context, payload) { + context.commit("update_loading", true); + try { + payload.token = one_token() + payload.supplierID = context.state.selectedSupplier.SupplierID + + let response = await api.getDefaultSupplierPrice(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + }; + + context.commit("update_loading", false); + + return data.records; + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + }, +}; diff --git a/test/vuex/acc-one-approve-po-inventaris/store.js b/test/vuex/acc-one-approve-po-inventaris/store.js new file mode 100644 index 0000000..e107174 --- /dev/null +++ b/test/vuex/acc-one-approve-po-inventaris/store.js @@ -0,0 +1,14 @@ +// import manager from "./modules/manager.js"; +// import prkacab from "./modules/prkacab.js" +import system from "../../../apps/modules/system/system.js"; +import po from "./modules/po.js"; + +export const store = new Vuex.Store({ + modules: { + po: po, + system: system + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-approve-po-jasa/api/api.js b/test/vuex/acc-one-approve-po-jasa/api/api.js new file mode 100644 index 0000000..c0c0fc5 --- /dev/null +++ b/test/vuex/acc-one-approve-po-jasa/api/api.js @@ -0,0 +1,162 @@ +const URL = "/one-api/mockup/purchase/order/PurchaseOrderService/"; +const URLRO = "/one-api/mockup/receive-item-po/ReceiveOrderService/"; + +export async function getDaftarCabang(params) { + try { + var response = await axios.post(URL + "getDaftarCabang", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarSupplier(params) { + try { + var response = await axios.post(URL + "getDaftarSupplier", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarPOJasa(params) { + try { + var response = await axios.post(URL + "getDaftarPOJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataKontrakPOJasa(params) { + try { + var response = await axios.post(URL + "getDataKontrakPOJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var response = await axios.post(URL + "getUserApproveLevel", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function updateApprovalPO(params) { + try { + var response = await axios.post(URL + "updateApprovalPO", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function generatePOItemReceive(params) { + try { + const response = await axios.post(URLRO + "generatePOItemReceive", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + const data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarAttachment(params) { + try { + const response = await axios.post(URL + "getDaftarAttachment", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + const data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-jasa/components/dialog-confirm.vue b/test/vuex/acc-one-approve-po-jasa/components/dialog-confirm.vue new file mode 100644 index 0000000..23d6973 --- /dev/null +++ b/test/vuex/acc-one-approve-po-jasa/components/dialog-confirm.vue @@ -0,0 +1,364 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-jasa/components/dialog-view-attachment.vue b/test/vuex/acc-one-approve-po-jasa/components/dialog-view-attachment.vue new file mode 100644 index 0000000..50bc58b --- /dev/null +++ b/test/vuex/acc-one-approve-po-jasa/components/dialog-view-attachment.vue @@ -0,0 +1,104 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-jasa/components/one-layout-service.vue b/test/vuex/acc-one-approve-po-jasa/components/one-layout-service.vue new file mode 100644 index 0000000..68b2cae --- /dev/null +++ b/test/vuex/acc-one-approve-po-jasa/components/one-layout-service.vue @@ -0,0 +1,275 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-jasa/index.php b/test/vuex/acc-one-approve-po-jasa/index.php new file mode 100644 index 0000000..c9f3033 --- /dev/null +++ b/test/vuex/acc-one-approve-po-jasa/index.php @@ -0,0 +1,60 @@ + + + + + + + + + + One + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-jasa/modules/poservice.js b/test/vuex/acc-one-approve-po-jasa/modules/poservice.js new file mode 100644 index 0000000..754f0c2 --- /dev/null +++ b/test/vuex/acc-one-approve-po-jasa/modules/poservice.js @@ -0,0 +1,231 @@ +import * as api from '../api/api.js'; + +export default { + namespaced: true, + state: { + /* utility */ + snackbar: { + color: 'success', + msg: '', + state: false + }, + + filterjasa: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + status: "All", + search: "" + }, + liststatus: ['All', 'Draft', 'Pending', 'Approved', 'Rejected', 'Completed'], + list_pojasa: { + records: [], + total: 0 + }, + currpage: 1, + loading_process: false, + list_supplier: [], + list_branch: [], + userinfo: {}, + + /* dialog konfirmasi */ + dialog_confirm: false, + detail_view: false, + selected_pojasa: { + summary: { + subtotal: 0.00, + diskon: 0.00, + pajak: 0.00, + total: 0.00 + } + }, + + /* dialog attachment */ + dialog_attachment: false, + prview_attachment: [] + }, + mutations: { + update_snackbar(state, val) { + state.snackbar = val + }, + update_filterjasa(state, val) { + state.filterjasa = val + }, + update_liststatus(state, val) { + state.liststatus = val + }, + update_list_pojasa(state, val) { + state.list_pojasa = val + }, + update_currpage(state, val) { + state.currpage = val + }, + update_loading_process(state, val) { + state.loading_process = val + }, + update_list_supplier(state, val) { + state.list_supplier = val + }, + update_list_branch(state, val) { + state.list_branch = val + }, + update_userinfo(state, val) { + state.userinfo = val + }, + update_dialog_confirm(state, val) { + state.dialog_confirm = val + }, + update_detail_view(state, val) { + state.detail_view = val + }, + update_selected_pojasa(state, val) { + state.selected_pojasa = val + }, + update_dialog_attachment(state, val) { + state.dialog_attachment = val + }, + update_prview_attachment(state, val) { + state.prview_attachment = val + } + }, + actions: { + async lookupCabang(context) { + try { + const resp = await api.getDaftarCabang({token: one_token()}) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_list_branch", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupVendor(context) { + try { + const resp = await api.getDaftarSupplier({token: one_token()}) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_list_supplier", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupPOJasa(context) { + try { + let param = { + token: one_token(), + currpage: context.state.currpage, + ...context.state.filterjasa + } + + const resp = await api.getDaftarPOJasa(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit('update_list_pojasa', resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupDetailPO(context, poid) { + try { + let param = { + token: one_token(), + poID: poid + } + + const resp = await api.getDataKontrakPOJasa(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_selected_pojasa", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupUserApproveLevel(context) { + try { + const resp = await api.getUserApproveLevel({token: one_token()}) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_userinfo", resp.data) + } + + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupAttachment(context, param) { + try { + param.token = one_token() + const resp = await api.getDaftarAttachment(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit('update_prview_attachment', resp.data) + } + + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async updateApprovePO(context) { + try { + context.state.loading_process = true; + + const jasa = context.state.selected_pojasa; + const param = { + token: one_token(), + approvelevel: context.state.userinfo.M_UserM_ApproveLevelID, + poID: jasa.PurchaseOrderID, + kontrakid: jasa.T_KontrakJasaID + }; + + const resp = await api.updateApprovalPO(param); + if (resp.status !== 'OK') { + throw new Error(resp.message); + } + + if (param.approvelevel === '2') { + const generate = await api.generatePOItemReceive(param); + if (generate.status !== 'OK') { + throw new Error(generate.message); + } + } + + let snac = {color: 'success', msg: resp.data, state: true}; + context.commit('update_snackbar', snac); + context.dispatch('lookupPOJasa'); + context.state.dialog_confirm = false + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true}; + context.commit('update_snackbar', snac); + } finally { + context.state.loading_process = false; + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po-jasa/store.js b/test/vuex/acc-one-approve-po-jasa/store.js new file mode 100644 index 0000000..ec6d4dd --- /dev/null +++ b/test/vuex/acc-one-approve-po-jasa/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js"; +import poservice from "./modules/poservice.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + poservice: poservice + }, + state: {}, + mutations: {}, + actions: {} +}); \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po/api/po.js b/test/vuex/acc-one-approve-po/api/po.js new file mode 100644 index 0000000..a6dbfaf --- /dev/null +++ b/test/vuex/acc-one-approve-po/api/po.js @@ -0,0 +1,293 @@ +const URL = "/one-api/mockup/purchase/order/PurchaseOrderV2/"; +const URLRO = "/one-api/mockup/receive-item-po/receiveitempo/"; + +export async function getSupplier(payload) { + try { + var response = await axios.post(URL + "getSupplier", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItemCategory(payload) { + try { + var response = await axios.post(URL + "getItemCategory", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getWarehouse(payload) { + try { + var response = await axios.post(URL + "getWarehouse", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItem(payload) { + try { + var response = await axios.post(URL + "getItem", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItemUpdate(payload) { + try { + var response = await axios.post(URL + "getItemUpdate", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function saveOrder(payload) { + try { + var response = await axios.post(URL + "saveOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function search(payload) { + try { + var response = await axios.post(URL + "search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function requestOrder(payload) { + try { + var response = await axios.post(URL + "requestOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteOrder(payload) { + try { + var response = await axios.post(URL + "deleteOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateOrder(payload) { + try { + var response = await axios.post(URL + "updateOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approvePOrder(payload) { + try { + var response = await axios.post(URL + "approvePOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function isValidMultipleWarehouse(payload) { + try { + var response = await axios.post(URL + "isValidMultipleWarehouse", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function generateItemPO(params) { + try { + var response = await axios.post(URLRO + "generateItemPo", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getApprovalLevel(params) { + try { + var response = await axios.post(URL + 'getApproveLevel', params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getDefaultSupplierPrice(payload) { + try { + var response = await axios.post(URL + "getDefaultSupplierPrice", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po/components/dialogView.vue b/test/vuex/acc-one-approve-po/components/dialogView.vue new file mode 100644 index 0000000..6ff7f41 --- /dev/null +++ b/test/vuex/acc-one-approve-po/components/dialogView.vue @@ -0,0 +1,593 @@ + + + + + diff --git a/test/vuex/acc-one-approve-po/components/po.vue b/test/vuex/acc-one-approve-po/components/po.vue new file mode 100644 index 0000000..32d57c3 --- /dev/null +++ b/test/vuex/acc-one-approve-po/components/po.vue @@ -0,0 +1,713 @@ + + + + + diff --git a/test/vuex/acc-one-approve-po/components/poForm.vue b/test/vuex/acc-one-approve-po/components/poForm.vue new file mode 100644 index 0000000..9e0674c --- /dev/null +++ b/test/vuex/acc-one-approve-po/components/poForm.vue @@ -0,0 +1,1509 @@ + + + + + diff --git a/test/vuex/acc-one-approve-po/functions/functions.js b/test/vuex/acc-one-approve-po/functions/functions.js new file mode 100644 index 0000000..7e3d2ca --- /dev/null +++ b/test/vuex/acc-one-approve-po/functions/functions.js @@ -0,0 +1,475 @@ +/** + * Utility functions for the ACC One Purchase Order application + */ + +// /** +// * Groups an array of objects by a specified key +// * @param {Array} array - The array of objects to group +// * @param {String} key - The key to group by +// * @returns {Object} - An object with keys representing the grouped values and arrays as values +// */ +// export const groupBy = (array, key) => { +// return array.reduce((result, item) => { +// const groupKey = item[key]; +// if (!result[groupKey]) { +// result[groupKey] = []; +// } +// result[groupKey].push(item); +// return result; +// }, {}); +// }; +/** + * Groups an array of objects by one or multiple keys + * @param {Array} array - The array of objects to group + * @param {Function|String|Array} key - The key(s) to group by. Can be a string, array of strings, or a function. + * @returns {Object} - An object with keys representing the grouped values and arrays as values + */ +export const groupBy = (array, key) => { + return array.reduce((result, item) => { + let groupKey; + + // Handle single key (string), multiple keys (array), or custom function + if (typeof key === 'function') { + groupKey = key(item); + } else if (Array.isArray(key)) { + groupKey = key.map(k => item[k]).join('_'); // Combine multiple keys with underscore + } else { + groupKey = item[key]; + } + + if (!result[groupKey]) { + result[groupKey] = []; + } + result[groupKey].push(item); + return result; + }, {}); +}; + +/** + * Groups purchase request data by M_ItemID + * Terjadi jika ada beberapa item yang sama, maka akan digabungkan berdasarkan M_ItemID dan PoItemUnitID + * @param {Array} purchaseRequestData - Array of purchase request objects + * @returns {Array} - Array of objects with M_ItemID, M_ItemCode, M_ItemDesc, unit information, converted PoQty, and Details array + */ +export const groupPurchaseRequestsByItemId_old = (purchaseRequestData) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']); + console.log("grouped"); + console.log(grouped); + + return Object.keys(grouped).map(itemId => { + const items = grouped[itemId]; + const firstItem = items[0]; + + /* Sebelum Kalkulasi Konversi Item di BE */ + // // Calculate total PoQty from all items + // const totalPoQty = calculateTotalQuantity(items, 'PoQty'); + // // Get the conversion factor from the first item + // const conversionFactor = Number(firstItem.DefaultPurchase.UnitConvertAmount) || 1; + // // Convert the total quantity and round up if it's a decimal + // const convertedPoQty = Math.ceil(convertUnits(totalPoQty, conversionFactor)); + + /* Sesudah Kalkulasi Konversi Item di BE getItem() */ + const convertedPoQty = calculateTotalQuantity(items, 'PoQty') + console.log("Total PoQty for itemId", itemId, " : ", convertedPoQty); + + let price = 0; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - (Number(firstItem.discount) * (Number(firstItem.DefaultPurchase.SupplierPricePrice) / 100)); + } + if (firstItem.discountType === 'R') { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - Number(firstItem.discount); + } + + } else { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + } + + // Get the price from the first item + const realPrice = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + + // Calculate the total (PoQty * price) + const total = convertedPoQty * price; + + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + TotalPoQty: convertedPoQty, + Price: price, + RealPrice: realPrice, + PriceAfterDiscount: price, + Total: total, + Details: items + }; + }); +}; + +export const groupPurchaseRequestsByItemId = async (purchaseRequestData, context) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']); + console.log("grouped", grouped); + + const results = await Promise.all(Object.keys(grouped).map(async (itemId) => { + const items = grouped[itemId]; + const firstItem = items[0]; + + const convertedPoQty = calculateTotalQuantity(items, 'PoQty'); + console.log("Total PoQty for itemId", itemId, ":", convertedPoQty); + + // Fetch the default supplier price based on the first item's M_ItemID and the converted quantity + // penambahan multi harga di PO (untuk mendapatkan harga sesuai qty) + const supplierPrice = await context.dispatch('getDefaultSupplierPrice', { + itemID: firstItem.M_ItemID, + qty: convertedPoQty + }); + + if (supplierPrice == null) { + let snackbar = { + state: true, + type: "warning", + message: `Jumlah Quantity tidak tersedia di rentang harga supplier untuk item ${firstItem.M_ItemDesc}!`, + }; + context.commit("update_snackbar", snackbar); + context.commit("update_supplierPriceSave", supplierPrice); + context.commit("update_itemDesc", firstItem.M_ItemDesc); + } else { + context.commit("update_supplierPriceSave", supplierPrice); + context.commit("update_itemDesc", ''); + } + + let price = 0; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + price = Number(supplierPrice?.SupplierPricePrice || 0) - (Number(firstItem.discount) * (Number(supplierPrice?.SupplierPricePrice || 0) / 100)); + } else if (firstItem.discountType === 'R') { + price = Number(supplierPrice?.SupplierPricePrice || 0) - Number(firstItem.discount); + } + } else { + price = Number(supplierPrice?.SupplierPricePrice || 0) || 0; + } + + const total = convertedPoQty * price; + + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + TotalPoQty: convertedPoQty, + Price: price, + RealPrice: Number(supplierPrice?.SupplierPricePrice || 0), + PriceAfterDiscount: price, + Total: total, + Details: items + }; + })); + + return results; // hasil sudah dalam bentuk array berisi semua item lengkap +}; + +/** + * Formats a number as currency (IDR) + * @param {Number} amount - The amount to format + * @returns {String} - Formatted currency string + */ +export const formatCurrency = (amount) => { + return new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }).format(amount); +}; + +/** + * Formats a date to a localized string + * @param {Date|String} date - The date to format + * @param {Object} options - Intl.DateTimeFormat options + * @returns {String} - Formatted date string + */ +export const formatDate = (date, options = { + year: 'numeric', + month: 'long', + day: 'numeric' +}) => { + if (!date) return ''; + const dateObj = typeof date === 'string' ? new Date(date) : date; + return new Intl.DateTimeFormat('id-ID', options).format(dateObj); +}; + +/** + * Calculates the total value of purchase requests + * @param {Array} items - Array of purchase request items + * @returns {Number} - Total value + */ +export const calculateTotal = (items) => { + return items.reduce((sum, item) => sum + (Number(item.Total) || 0), 0); +}; + +/** + * Calculates the total quantity of items + * @param {Array} items - Array of purchase request items + * @param {String} qtyField - The field name containing quantity (e.g., 'PoQty') + * @returns {Number} - Total quantity + */ +export const calculateTotalQuantity = (items, qtyField = 'PoQty') => { + console.log("Items in calculateTotalQuantity:", items); + return items.reduce((sum, item) => sum + (Number(item[qtyField]) || 0), 0); +}; + +/** + * Converts units based on the conversion factor + * @param {Number} quantity - The quantity to convert + * @param {Number} conversionFactor - The conversion factor + * @returns {Number} - Converted quantity + */ +export const convertUnits = (quantity, conversionFactor) => { + return quantity / conversionFactor; +}; + +/** + * Filters purchase requests by branch + * @param {Array} items - Array of purchase request items + * @param {String|Array} branchCodes - Branch code(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByBranch = (items, branchCodes) => { + if (!branchCodes) return items; + + const codes = Array.isArray(branchCodes) ? branchCodes : [branchCodes]; + return items.filter(item => codes.includes(item.BranchCode)); +}; + +/** + * Filters purchase requests by regional + * @param {Array} items - Array of purchase request items + * @param {String|Array} regionalIds - Regional ID(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByRegional = (items, regionalIds) => { + if (!regionalIds) return items; + + const ids = Array.isArray(regionalIds) ? regionalIds : [regionalIds]; + return items.filter(item => ids.includes(item.S_RegionalID)); +}; + +/** + * Validates if a purchase request item has all required fields + * @param {Object} item - Purchase request item + * @returns {Boolean} - True if valid, false otherwise + */ +export const validatePurchaseRequestItem = (item) => { + const requiredFields = [ + 'M_ItemID', + 'M_ItemCode', + 'M_ItemDesc', + 'Price', + 'RequestQty' + ]; + + return requiredFields.every(field => item[field] !== undefined && item[field] !== null); +}; + +/** + * Sorts purchase request items by a specified field + * @param {Array} items - Array of purchase request items + * @param {String} field - Field to sort by + * @param {Boolean} ascending - Sort direction (true for ascending, false for descending) + * @returns {Array} - Sorted items + */ +export const sortPurchaseRequests = (items, field = 'M_ItemDesc', ascending = true) => { + return [...items].sort((a, b) => { + const valueA = a[field]; + const valueB = b[field]; + + if (typeof valueA === 'string' && typeof valueB === 'string') { + return ascending + ? valueA.localeCompare(valueB) + : valueB.localeCompare(valueA); + } + + return ascending + ? (valueA - valueB) + : (valueB - valueA); + }); +}; + +/** + * Validates purchase order data before saving + * @param {Object} context - Vuex context object + * @returns {Boolean} - Returns true if validation passes, false otherwise + */ +export const validatePurchaseOrder = (context) => { + if (context.state.loading) { + let snackbar = { + state: true, + type: "warning", + message: 'Loading sedang berlangsung harap menunggu ...', + }; + context.commit("update_snackbar", snackbar); + return false; + } + + let warningMsg = []; + if (context.state.selectedItem.length == 0) { + warningMsg.push('Belum memilih item'); + } + if (!context.state.refNumber || context.state.refNumber.trim() === '') { + warningMsg.push('Nomor Referensi belum diisi'); + } + if (!context.state.selectedWarehouse || !context.state.selectedWarehouse.WarehouseID && context.state.warehouseType !== 'Multiple') { + warningMsg.push('Tipe Gudang Single Harus memilih Gudang'); + } + if (!context.state.selectedSupplier || !context.state.selectedSupplier.SupplierID) { + warningMsg.push('Supplier belum dipilih'); + } + if (context.state.discountType === 'Percentage') { + const discountValue = (context.state.itemTotal.total * context.state.discountAmount) / 100; + if (discountValue > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } else if (context.state.discountType === 'Absolute') { + if (context.state.discountAmount > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } + + context.state.summary.forEach(element => { + if (Number(element.discount) < 0) { + warningMsg.push('Diskon ' + element.M_ItemDesc + ' tidak boleh kurang dari 0'); + } + if (element.discountType === 'P') { + if (Number(element.discount) > 100) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi 100'); + } + } + if (element.discountType === 'R') { + if (Number(element.discount) > Number(element.RealPrice)) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi dari harga'); + } + } + }); + + if (warningMsg.length > 0) { + let snackbar = { + state: true, + type: "warning", + message: warningMsg.join(", "), + }; + context.commit("update_snackbar", snackbar); + return false; + } + + return true; +}; + +/** + * Menghitung total summary untuk purchase order + * @param {Array} summary - Array data summary + * @param {Number} taxPpn - Persentase pajak PPN + * @param {Number} taxPph - Persentase pajak PPH + * @param {String} discountType - Tipe diskon ('Percentage' atau 'Absolute') + * @param {Number} discountAmount - Jumlah diskon + * @returns {Object} - Object summaryTotal + */ +export const calculateSummaryTotal = (summary, taxPpn = 0, taxPph = 0, discountType = 'Percentage', discountAmount = 0) => { + if (!summary || summary.length === 0) { + return { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }; + } + + // Hitung total dari item summary + const total = summary.reduce((acc, item) => acc + (Number(item.Total) || 0), 0); + + // Hitung diskon berdasarkan tipe + let discount = discountAmount; + if (discountType === 'Percentage') { + discount = (discountAmount / 100) * total; + } + + // Hitung pajak + const newTotal = total - discount; + const ppn = (taxPpn / 100) * newTotal; + const pph = (taxPph / 100) * newTotal; + const tax = ppn + pph; + const finalTotal = newTotal + tax; + + // Return object summaryTotal + return { + total: total, + tax: tax, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: finalTotal, + }; +}; + + +/** + * Menghapus item dari summary dan selectedItem berdasarkan itemId atau detailId + * @param {Array} summary - Array data summary + * @param {Array} selectedItem - Array data selectedItem + * @param {String} itemId - ID item yang akan dihapus (opsional) + * @param {String} detailId - ID detail yang akan dihapus (opsional) + * @returns {Object} - Object berisi summary dan selectedItem yang sudah diupdate + */ +export const deleteItemFromSummary = (summary, selectedItem, itemId = null, detailId = null) => { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = summary.filter(item => item.M_ItemID !== itemId); + const newSelectedItem = selectedItem.filter(item => item.M_ItemID !== itemId); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = selectedItem.filter(item => item.PurchaseRequestFlagID !== detailId); + + // Regenerate summary dari selectedItem yang baru + const newSummary = groupPurchaseRequestsByItemId(newSelectedItem); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + return { + summary, + selectedItem + }; +}; \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po/index.php b/test/vuex/acc-one-approve-po/index.php new file mode 100644 index 0000000..d3024d3 --- /dev/null +++ b/test/vuex/acc-one-approve-po/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-approve-po/modules/po.js b/test/vuex/acc-one-approve-po/modules/po.js new file mode 100644 index 0000000..9287dfb --- /dev/null +++ b/test/vuex/acc-one-approve-po/modules/po.js @@ -0,0 +1,1439 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/po.js"; +import { validatePurchaseOrder, groupPurchaseRequestsByItemId, calculateSummaryTotal } from "../functions/functions.js"; + +export default { + namespaced: true, + state: { + statusOptions: [ + { value: 'All', title: "All" }, + { value: 'Draft', title: "Draft" }, + { value: 'Pending', title: "Pending" }, + { value: 'Approved', title: "Approved" }, + { value: 'Rejected', title: "Rejected" }, + { value: 'Completed', title: "Completed" }, + ], + selectedStatus: { value: 'All', title: "All" }, + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + search: '', + totalPage: 0, + selectedPage: 1, + loading: false, + poList: [ + { + "poNumber": "PO1234566", + "poDate": "01-01-2025", + "poVendor": "PT ABC 123", + "poTotal": "1000000", + "poStatus": "DRAFT", + } + ], + dialogForm: false, + detailData: [], + selectedPr: {}, + loadingDetail: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + //FORM + selectedDateForm: moment(new Date()).format('YYYY-MM-DD'), + selectedDateEnd: moment(new Date()).format('YYYY-MM-DD'), + selectedSupplier: {}, + refNumber: '', + taxPpn: 0, + taxPph: 0, + paymentTerm: 0, + discountType: 'Percentage', + discountTypeList: ['Percentage', 'Absolute'], + discountAmount: 0, + note: '', + warehouseTypeList: ['Single', 'Multiple'], + warehouseType: 'Single', + warehouseList: [], + selectedWarehouse: {}, + itemList: [], + selectedItemTemp: [], + selectedItem: [], + searchItem: '', + itemTotal: { + total: 0, + ppn: 0, + pph: 0, + tax: 0, + discount: 0, + finalTotal: 0, + }, + defaultWarehouse: {}, + shippingCost: 0, + shippingCostStatus: true,//Sudah di bayar atau belum + //END FORM + supplierList: [], + loadingAutocomplete: false, + searchSupplier: "", + dialogConfirmation: false, + dialogDelete: false, + selectedPO: {}, + dialogItem: false, + currentPageItem: 1, + totalPageItem: 0, + dialogFormAct: 'ADD', + summary: [], + summaryTotal: { + total: 0, + ppn: 0, + pph: 0, + tax: 0, + discount: 0, + finalTotal: 0, + }, + deletedItem: [],//kalau edit item sebelumnya yang dihapus masuk sini agar bisa dipilih lagi , + dialogView: false, + itemCategoryList: [], + selectedItemCategory: {}, + open_print: false, + // isValidMultipleWarehouse: false, // Flag untuk validasi multiple warehouse + isValidMultipleWarehouse: { + status: false, + message: '', + }, + approve_level: 0, + status: '', + xstartdate: '', + supplierPriceSave: null, + itemDesc: '', + flag: '' + }, + mutations: { + update_shippingCost(state, val) { + state.shippingCost = val; + }, + update_shippingCostStatus(state, val) { + state.shippingCostStatus = val; + }, + update_selectedItemCategory(state, val) { + state.selectedItemCategory = val; + }, + update_itemCategoryList(state, val) { + state.itemCategoryList = val; + }, + update_dialogView(state, val) { + state.dialogView = val; + }, + update_deletedItem(state, val) { + state.deletedItem = val; + }, + update_summaryTotal(state, val) { + state.summaryTotal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialogFormAct(state, val) { + state.dialogFormAct = val; + }, + update_totalPageItem(state, val) { + state.totalPageItem = val; + }, + update_currentPageItem(state, val) { + state.currentPageItem = val; + }, + update_dialogItem(state, val) { + state.dialogItem = val; + }, + update_selectedPO(state, val) { + state.selectedPO = val; + }, + update_dialogDelete(state, val) { + state.dialogDelete = val; + }, + update_dialogConfirmation(state, val) { + state.dialogConfirmation = val; + }, + update_defaultWarehouse(state, val) { + state.defaultWarehouse = val; + }, + update_itemTotal(state, val) { + state.itemTotal = val; + }, + update_searchItem(state, val) { + state.searchItem = val; + }, + update_selectedItemTemp(state, val) { + state.selectedItemTemp = val; + }, + update_selectedItem(state, val) { + state.selectedItem = val; + }, + update_itemList(state, val) { + state.itemList = val; + }, + update_warehouseList(state, val) { + state.warehouseList = val; + }, + update_supplierList(state, val) { + state.supplierList = val; + }, + update_searchSupplier(state, val) { + state.searchSupplier = val; + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + update_selectedWarehouse(state, val) { + state.selectedWarehouse = val; + }, + update_warehouseTypeList(state, val) { + state.warehouseTypeList = val; + }, + update_warehouseType(state, val) { + state.warehouseType = val; + // Disable and clear selectedWarehouse when type is Multiple + if (val === 'Multiple') { + state.selectedWarehouse = {}; + } + }, + update_note(state, val) { + state.note = val; + }, + update_discountAmount(state, val) { + // debugger; + if (state.discountType === 'Percentage' && val > 100) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Diskon tidak boleh lebih dari 100', + }; + state.discountAmount = 100; + return; + } + if (state.discountType === 'Absolute' && val > state.itemTotal.total && state.itemTotal.total > 0) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Diskon tidak boleh lebih dari total', + }; + state.discountAmount = state.itemTotal.total; + return; + } + state.discountAmount = val; + }, + update_discountType(state, val) { + state.discountType = val; + }, + update_paymentTerm(state, val) { + state.paymentTerm = val; + }, + update_taxPpn(state, val) { + if (val > 0) { + state.taxPpn = val; + } else { + state.taxPpn = 0; + } + }, + update_taxPph(state, val) { + if (val > 0) { + state.taxPph = val; + } else { + state.taxPph = 0; + } + }, + update_refNumber(state, val) { + state.refNumber = val; + }, + update_selectedSupplier(state, val) { + state.selectedSupplier = val; + }, + update_selectedDateForm(state, val) { + state.selectedDateForm = val; + }, + update_selectedDateEnd(state, val) { + state.selectedDateEnd = val; + }, + update_snackbar(state, val) { + state.snackbar = val; + }, + update_loadingDetail(state, val) { + state.loadingDetail = val; + }, + update_selectedPr(state, val) { + state.selectedPr = val; + }, + update_detailData(state, val) { + state.detailData = val; + }, + update_dialogForm(state, val) { + state.dialogForm = val; + }, + update_selectedStatus(state, val) { + state.selectedStatus = val; + }, + update_selectedDate(state, val) { + state.selectedDate = val; + }, + update_search(state, val) { + state.search = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_totalPage(state, val) { + state.totalPage = val; + }, + update_selectedPage(state, val) { + state.selectedPage = val; + }, + update_poList(state, val) { + state.poList = val; + }, + update_open_print(state, value) { + state.open_print = value + }, + update_isValidMultipleWarehouse(state, value) { + state.isValidMultipleWarehouse = value; + }, + update_approve_level(state, data) { + state.approve_level = data + }, + update_status(state, val) { + state.status = val + }, + update_xstartdate(state, val) { + state.xstartdate = val + }, + update_supplierPriceSave(state, val) { + state.supplierPriceSave = val; + }, + update_itemDesc(state, val) { + state.itemDesc = val; + }, + update_flag(state, val) { + state.flag = val + } + }, + actions: { + async deleteItemFromSummary(context, { itemId = null, detailId = null }) { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = context.state.summary.filter(item => item.keyID !== itemId); + const newSelectedItem = context.state.selectedItem.filter(item => item.keyID !== itemId); + if (context.state.dialogFormAct === 'EDIT') { + let deletedItemBefore = JSON.parse(JSON.stringify(context.state.deletedItem)) + const deletedItem = context.state.selectedItem.filter(item => item.keyID === itemId + && item.PurchaseOrderDetailID !== undefined + && item.PurchaseOrderDetailID !== null + && item.PurchaseOrderDetailID !== 0); + let newDeletedItem = [] + deletedItem.forEach(de => { + let cek = deletedItemBefore.find((element) => + element.M_ItemID === de.M_ItemID + && element.PurchaseRequestFlagID === de.PurchaseRequestFlagID + && element.PurchaseOrderDetailID === de.PurchaseOrderDetailID) + if (!cek) { + newDeletedItem.push(de) + } + }); + context.commit('update_deletedItem', [...deletedItemBefore, ...newDeletedItem]); + } + context.commit('update_summary', newSummary); + context.commit('update_selectedItem', newSelectedItem); + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = context.state.selectedItem.filter( + item => item.PurchaseRequestFlagID !== detailId + ); + if (context.state.dialogFormAct === 'EDIT') { + let deletedItemBefore = JSON.parse(JSON.stringify(context.state.deletedItem)) + const deletedItem = context.state.selectedItem.filter( + item => item.PurchaseRequestFlagID === detailId + && item.PurchaseOrderDetailID !== undefined + && item.PurchaseOrderDetailID !== null + && item.PurchaseOrderDetailID !== 0 + ); + let newDeletedItem = [] + deletedItem.forEach(de => { + let cek = deletedItemBefore.find((element) => + element.M_ItemID === de.M_ItemID + && element.PurchaseRequestFlagID === de.PurchaseRequestFlagID + && element.PurchaseOrderDetailID === de.PurchaseOrderDetailID) + if (!cek) { + newDeletedItem.push(de) + } + }); + context.commit('update_deletedItem', [...deletedItemBefore, ...newDeletedItem]); + } + + // Regenerate summary dari selectedItem yang baru + const newSummary = await groupPurchaseRequestsByItemId(newSelectedItem, context); + + context.commit('update_summary', newSummary); + context.commit('update_selectedItem', newSelectedItem); + } + + // Hitung ulang total + context.dispatch('countItemTotal'); + context.dispatch('generateSummary'); + }, + + generateSummaryTotal(context) { + const summaryTotal = calculateSummaryTotal( + context.state.summary, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + context.commit('update_summaryTotal', summaryTotal); + }, + + async generateSummary(context) { + let data = JSON.parse(JSON.stringify(context.state.selectedItem)); + console.log("Data untuk param groupPurchaseRequestsByItemId:", JSON.parse(JSON.stringify(data))); + + /** + * Tambah validasi: + * > Apakah bisa multiple warehouse? + */ + context.dispatch('isValidMultipleWarehouse'); + + if (context.state.warehouseType === "Multiple") { + data.forEach((element) => { + element.warehouse = { + WarehouseID: element.WarehouseID, + WarehouseName: element.WarehouseName, + }; + }); + } else if (context.state.warehouseType === "Single") { + data.forEach((element) => { + element.warehouse = context.state.selectedWarehouse; // Semua item pakai warehouse yang sama + }); + } + + let summary = await groupPurchaseRequestsByItemId(data, context); + context.commit('update_summary', summary); + console.log("Summary setelah grouping:", JSON.parse(JSON.stringify(summary))); + + // Hitung summary total menggunakan fungsi dari functions.js + const summaryTotal = calculateSummaryTotal( + summary, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + }, + + multipleWarehouseValidation(context, selectedItem) { + let data; + + if (!selectedItem || selectedItem.length === 0) { + data = JSON.parse(JSON.stringify(context.state.selectedItem)); + } else { + data = JSON.parse(JSON.stringify(selectedItem)); + } + + // Pakai 'Set' JS Object yang hanya menyimpan nilai unik. + const warehouseIds = new Set(); + + data.forEach(item => { + if (item.WarehouseID) { + // Kalau ada yang sama maka disimpan sekali. + warehouseIds.add(item.WarehouseID); + } + }); + + if (warehouseIds.size > 1) { + return true; // Ada lebih dari satu WarehouseID + } else { + return false; // Hanya ada satu WarehouseID + } + }, + + async isValidMultipleWarehouse(context) { + /** + * @param: array of PurchaseRequestDetailID dari selectedItem + * @api: api.isValidMultipleWarehouse + * @return: JSON -> {data.status (boolean), data.message (string)} + * + */ + if (context.state.selectedItem.length === 0) { + return false; // Tidak ada item yang dipilih + } + try { + let payload = { + "PurchaseRequestDetailIDs": context.state.selectedItem.map(item => item.PurchaseRequestDetailID), + "token": one_token(), + }; + + let response = await api.isValidMultipleWarehouse(payload) + + console.log("Payload untuk isValidMultipleWarehouse:", JSON.parse(JSON.stringify(payload.PurchaseRequestDetailIDs))); + console.log("Response dari isValidMultipleWarehouse:", JSON.parse(JSON.stringify(response))); + + if (response.status !== "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_isValidMultipleWarehouse", { + status: false, + message: '', + }); + context.commit("update_snackbar", snackbar); + } else {; + context.commit("update_isValidMultipleWarehouse", { + status: response.data.status, + message: response.data.message, + }); + if(response.data.status == false) { + context.commit("update_warehouseType", 'Single'); + context.commit("update_selectedWarehouse", context.state.selectedWarehouse); + } + }; + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + } + }, + + assignEdit(context) { + let data = context.state.selectedPO + context.commit("update_selectedDateForm", data.PurchaseOrderDate); + context.commit("update_searchSupplier", data.SupplierName); + context.commit("update_selectedSupplier", { + "SupplierID": data.PurchaseOrderSupplierID, + "SupplierCode": data.SupplierCode, + "SupplierName": data.SupplierName + }); + context.commit("update_selectedItemCategory", { + "itemCategoryID": data.itemCategoryID, + "itemCategoryName": data.itemCategoryName + }); + context.commit("update_refNumber", data.PurchaseOrderRefNumber); + context.commit("update_shippingCost", data.PurchaseOrderShippingCost); + context.commit("update_shippingCostStatus", data.PurchaseOrderShippingCostStatus === 'Y' ? true : false); + context.commit("update_taxPpn", data.PurchaseOrderTaxPercentPpn); + context.commit("update_taxPph", data.PurchaseOrderTaxPercentPph); + context.commit("update_paymentTerm", data.PurchaseOrderPaymentTerm); + context.commit("update_discountType", data.PurchaseOrderDiscountPercent > 0 ? 'Percentage' : 'Absolute'); + if (data.PurchaseOrderDiscountPercent > 0) { + context.commit("update_discountAmount", parseFloat(data.PurchaseOrderDiscountPercent)); + } else { + context.commit("update_discountAmount", parseFloat(data.PurchaseOrderDiscountAmount)); + } + context.commit("update_note", data.PurchaseOrderNote); + context.commit("update_warehouseType", data.PurchaseOrderWarehouseType); + context.commit("update_selectedWarehouse", { + "WarehouseID": data.PurchaseOrderWarehouseID, + "WarehouseCode": data.WarehouseCode, + "WarehouseName": data.WarehouseName, + }); + context.commit("update_dialogFormAct", 'EDIT'); + context.dispatch("countItemTotal"); + }, + + resetForm(context) { + context.commit("update_selectedDateForm", moment(new Date()).format('YYYY-MM-DD')); + context.commit("update_selectedSupplier", {}); + context.commit("update_refNumber", ''); + context.commit("update_taxPpn", 0); + context.commit("update_taxPph", 0); + context.commit("update_paymentTerm", 0); + context.commit("update_discountType", 'Percentage'); + context.commit("update_discountAmount", 0); + context.commit("update_note", ''); + context.commit("update_warehouseType", 'Single'); + context.commit("update_selectedWarehouse", context.state.defaultWarehouse); + context.commit("update_itemList", []); + context.commit("update_selectedItemTemp", []); + context.commit("update_selectedItem", []); + context.commit("update_deletedItem", []); + context.commit("update_selectedItemCategory", {}); + context.commit("update_summary", []); + context.commit("update_searchItem", ''); + context.commit("update_shippingCost", 0); + context.commit("update_shippingCostStatus", true); + context.commit("update_dialogFormAct", 'ADD'); + context.commit("update_summaryTotal", { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }); + context.commit("update_itemTotal", { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }); + }, + + countItemTotal(context) { + let selectedItem = context.state.selectedItem; + if (selectedItem.length === 0) { + let hasil = { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + } + context.commit("update_itemTotal", hasil); + return; + } + + // Fix: Ensure we're working with numeric values + let total = selectedItem.reduce((acc, item) => { + // Convert string to number if needed + const itemTotal = typeof item.Total === 'string' ? + parseFloat(item.Total.replace(/\./g, '').replace(',', '.')) : + item.Total; + return acc + (isNaN(itemTotal) ? 0 : itemTotal); + }, 0); + + total = Math.round(total * 100) / 100; + + let discount = parseFloat(context.state.discountAmount) || 0; + if (context.state.discountType === 'Percentage') { + discount = Math.round((discount / 100) * total * 100) / 100; + } + + let newTotal = Math.round((total - discount) * 100) / 100; + let ppn = Math.round((parseFloat(context.state.taxPpn) / 100) * newTotal * 100) / 100; + let pph = Math.round((parseFloat(context.state.taxPph) / 100) * newTotal * 100) / 100; + let pajak = Math.round((ppn + pph) * 100) / 100; + let final = Math.round((newTotal + pajak) * 100) / 100; + + let hasil = { + total: total, + tax: pajak, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: final, + } + context.commit("update_itemTotal", hasil); + }, + + updatePoQty(context, { itemId, newPoQty }) { + let updatedSelectedItem = context.state.selectedItem.map(item => { + if (item.PurchaseRequestFlagID === itemId) { + // Convert string to number and ensure minimum value of 1 + const numericPoQty = Number(newPoQty); + item.PoQty = Math.max(1, Math.floor(isNaN(numericPoQty) ? 1 : numericPoQty)); + + // Recalculate item total + let price = item.DefaultPurchase?.SupplierPricePrice || 0; + + // Apply discount if exists + if (item.discount > 0) { + if (item.discountType === 'P') { + price = price - (item.discount * price / 100); + } else if (item.discountType === 'R') { + price = price - item.discount; + } + } + + item.Total = item.PoQty * price; + } + return item; + }); + + context.commit('update_selectedItem', updatedSelectedItem); + + // Regenerate summary + context.dispatch('generateSummary'); + context.dispatch('countItemTotal'); + context.dispatch('generateSummaryTotal'); + }, + + async getSupplier(context) { + if (context.state.searchSupplier.length < 2) return; + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + token: one_token(), + search: context.state.searchSupplier, + + }; + + let response = await api.getSupplier(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_supplierList", data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getItemCategory(context) { + + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + token: one_token(), + + }; + + let response = await api.getItemCategory(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_itemCategoryList", data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getWarehouse(context) { + + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + regionalId: one_user().S_RegionalID, + token: one_token(), + }; + + let response = await api.getWarehouse(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + response.data.records.forEach(element => { + if (element.WarehouseIsDefault === 'Y') { + context.commit("update_defaultWarehouse", element); + } + + }); + context.commit("update_warehouseList", response.data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getItem(context) { + context.commit("update_loading", true); + try { + var payload = { + "search": context.state.searchItem, + "currentPage": context.state.currentPageItem, + "supplierID": context.state.selectedSupplier.SupplierID, + "itemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "regionalId": one_user().S_RegionalID, + "token": one_token(), + }; + + let response = await api.getItem(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_itemList", data.records); + context.commit("update_totalPageItem", data.total); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getItemUpdate(context) { + context.commit("update_loading", true); + try { + var payload = { + "POID": context.state.selectedPO.PurchaseOrderID, + "token": one_token(), + }; + + let response = await api.getItemUpdate(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_selectedItem", data.records); + /** + * Tambah validasi: + * > Apakah bisa multiple warehouse? + */ + context.dispatch('isValidMultipleWarehouse'); + + context.commit("update_summary", response.data.summary) + context.dispatch("countItemTotal"); + // Hitung summary total menggunakan fungsi dari functions.js + // TODO: Check ini akibat penyesuaian + const summaryTotal = calculateSummaryTotal( + response.data.summary, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async saveOrder(context) { + try { + if (!validatePurchaseOrder(context)) { + return; + } + + const invalidQtyItems = context.state.selectedItem.filter(item => { + // Convert string to number first + const poQty = Number(item.PoQty); + + // Check if conversion failed (NaN), is less than 1, or not an integer + return isNaN(poQty) || poQty < 1 || !Number.isInteger(poQty); + }); + + if (invalidQtyItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki quantity minimal 1", + } + context.commit("update_snackbar", snackbar); + return; + } + + // Validasi: Cek apakah ada item dengan harga supplier null + if (context.state.supplierPriceSave === null) { + let snackbar = { + state: true, + type: "error", + message: `Jumlah Quantity tidak tersedia di rentang harga supplier pada item ${context.state.itemDesc}!`, + } + context.commit("update_snackbar", snackbar); + return; + } + + context.commit("update_loading", true); + + var payload = { + "token": one_token(), + "Date": context.state.selectedDateForm, + "RefNumber": context.state.refNumber, + "SupplierID": context.state.selectedSupplier.SupplierID, + "ItemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "TaxPercent": context.state.taxPpn, + "PaymentTerm": context.state.paymentTerm, + "DiscountPercent": context.state.discountType === 'Percentage' ? context.state.discountAmount : 0, + "DiscountAmount": context.state.discountType === 'Absolute' ? context.state.discountAmount : 0, + "WarehouseType": context.state.warehouseType, + "WarehouseID": context.state.selectedWarehouse.WarehouseID, + "Note": context.state.note, + "SubTotal": context.state.summaryTotal.total, + "TaxPercentPph": context.state.taxPph, + "TaxPercentPpn": context.state.taxPpn, + "TaxAmount": context.state.summaryTotal.tax, + "TaxAmountPph": context.state.summaryTotal.pph, + "TaxAmountPpn": context.state.summaryTotal.ppn, + "GrandTotal": context.state.summaryTotal.finalTotal, + "ShippingCost": context.state.shippingCost, + "ShippingCostStatus": context.state.shippingCostStatus, + // "Details": detail, + "Summary": context.state.summary + }; + + // Validasi Total Tidak Boleh <0 + const financialChecks = [ + { value: payload.GrandTotal, name: "Total" }, + { value: payload.SubTotal, name: "Sub Total" }, + { value: payload.TaxAmount, name: "Pajak" }, + { value: payload.TaxAmountPph, name: "Pajak PPH" }, + { value: payload.TaxAmountPpn, name: "Pajak PPN" }, + { value: payload.DiscountAmount, name: "Diskon" }, + { value: payload.ShippingCost, name: "Biaya Ekspedisi" } + ]; + + for (const check of financialChecks) { + if (check.value < 0) { + let snackbar = { + state: true, + type: "error", + message: `${check.name} tidak boleh kurang dari 0`, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + return; + } + } + + let response = await api.saveOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil simpan data", + } + context.commit("update_snackbar", snackbar); + + + context.commit("update_loading", false); + context.commit("update_dialogForm", false); + context.dispatch("resetForm"); + context.dispatch("searchData"); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async searchData(context) { + context.commit("update_loading", true); + try { + + var url_string = window.location.href + var url = new URL(url_string); + var status = url.searchParams.get("status"); + var xstartdate = url.searchParams.get("startdate"); + var xsearch = url.searchParams.get("search"); + var xflag = url.searchParams.get("flag"); + + // untuk notifikasi + if (xflag == 'N') { + + if (xsearch != null && xsearch != '') { + context.commit("update_search", xsearch); + } + if (status != null && status != '') { + context.commit("update_selectedStatus", { value: status, title: status }); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedEndDate", xstartdate); + } + + } else if (xflag == 'G') { + // untuk get data param approve all + + if (status != null && status != '') { + context.commit("update_selectedStatus", { value: status, title: status }); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedDateEnd", moment(new Date()).format('YYYY-MM-DD')); + } + context.commit("update_flag", xflag); + + } + + var payload = { + "token": one_token(), + "currentPage": context.state.selectedPage, + "search": context.state.search, + "startDate": context.state.selectedDate, + "endDate": context.state.selectedDateEnd, + "status": context.state.selectedStatus.value, + "flag": context.state.flag + }; + + let response = await api.search(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("update_totalPage", response.data.totalPage); + context.commit("update_poList", data.records); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async requestOrder(context) { + context.commit("update_loading", true); + + try { + + var payload = { + "token": one_token(), + "ID": context.state.selectedPO.PurchaseOrderID, + }; + + let response = await api.requestOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil request order", + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + context.commit("update_dialogConfirmation", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async deleteOrder(context) { + context.commit("update_loading", true); + + try { + var payload = { + "token": one_token(), + "PurchaseOrderId": context.state.selectedPO.PurchaseOrderID, + }; + + let response = await api.deleteOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil hapus order", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + context.commit("update_dialogDelete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async updateOrder(context) { + try { + if (!validatePurchaseOrder(context)) { + return; + } + + const invalidQtyItems = context.state.selectedItem.filter(item => { + // Convert string to number first + const poQty = Number(item.PoQty); + + // Check if conversion failed (NaN), is less than 1, or not an integer + return isNaN(poQty) || poQty < 1 || !Number.isInteger(poQty); + }); + + console.log("InvalidQtyItem updateOrder", invalidQtyItems) + + if (invalidQtyItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki quantity minimal 1", + } + context.commit("update_snackbar", snackbar); + return; + } + + // Validasi: Cek apakah ada item dengan harga supplier null + if (context.state.supplierPriceSave === null) { + let snackbar = { + state: true, + type: "error", + message: `Jumlah Quantity tidak tersedia di rentang harga supplier pada item ${context.state.itemDesc}!`, + } + context.commit("update_snackbar", snackbar); + return; + } + + var payload = { + "token": one_token(), + "Date": context.state.selectedDateForm, + "RefNumber": context.state.refNumber, + "SupplierID": context.state.selectedSupplier.SupplierID, + "TaxPercent": context.state.taxPpn, + "PaymentTerm": context.state.paymentTerm, + "ItemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "DiscountPercent": context.state.discountType === 'Percentage' ? context.state.discountAmount : 0, + "DiscountAmount": context.state.discountType === 'Absolute' ? context.state.discountAmount : 0, + "WarehouseType": context.state.warehouseType, + "WarehouseID": context.state.selectedWarehouse.WarehouseID, + "Note": context.state.note, + "SubTotal": context.state.summaryTotal.total, + "TaxPercentPph": context.state.taxPph, + "TaxPercentPpn": context.state.taxPpn, + "TaxAmount": context.state.summaryTotal.tax, + "TaxAmountPph": context.state.summaryTotal.pph, + "TaxAmountPpn": context.state.summaryTotal.ppn, + "GrandTotal": context.state.summaryTotal.finalTotal, + "ShippingCost": context.state.shippingCost, + "ShippingCostStatus": context.state.shippingCostStatus, + "PO": context.state.selectedPO, + "Summary": context.state.summary, + "deletedItem": context.state.deletedItem, + "IsApprovalEdit": true, + }; + + // Validasi Total Tidak Boleh <0 + const financialChecks = [ + { value: payload.GrandTotal, name: "Total" }, + { value: payload.SubTotal, name: "Sub Total" }, + { value: payload.TaxAmount, name: "Pajak" }, + { value: payload.TaxAmountPph, name: "Pajak PPH" }, + { value: payload.TaxAmountPpn, name: "Pajak PPN" }, + { value: payload.DiscountAmount, name: "Diskon" }, + { value: payload.ShippingCost, name: "Biaya Ekspedisi" } + ]; + + for (const check of financialChecks) { + if (check.value < 0) { + let snackbar = { + state: true, + type: "error", + message: `${check.name} tidak boleh kurang dari 0`, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + return; + } + } + + context.commit("update_loading", true); + let response = await api.updateOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil simpan data", + } + context.commit("update_snackbar", snackbar); + + + context.commit("update_loading", false); + context.commit("update_dialogForm", false); + context.dispatch("resetForm"); + context.dispatch("searchData"); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async approveOrder(context, payload) { + context.commit("update_loading", true); + try { + payload.token = one_token() + payload.approvelevel = context.state.approve_level + + let response = await api.approvePOrder(payload); + if (response.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + if (context.state.approve_level == '2') { + let params = { token: one_token(), id: payload.poID } + let generateitempo = await api.generateItemPO(params) + if (generateitempo.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let snackbar = { + state: true, + type: "success", + message: "Berhasil approve order", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + } + } else { + let snackbar = { + state: true, + type: "success", + message: "Berhasil approve order manager", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + } + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getApprovalLevel(context) { + context.commit("update_loading", true); + try { + let response = await api.getApprovalLevel({token: one_token()}); + if (response.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = response.data.M_UserM_ApproveLevelID + + context.commit("update_approve_level", data) + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getDefaultSupplierPrice(context, payload) { + context.commit("update_loading", true); + try { + payload.token = one_token() + payload.supplierID = context.state.selectedSupplier.SupplierID + + let response = await api.getDefaultSupplierPrice(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + }; + + context.commit("update_loading", false); + + return data.records; + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + }, +}; diff --git a/test/vuex/acc-one-approve-po/store.js b/test/vuex/acc-one-approve-po/store.js new file mode 100644 index 0000000..e107174 --- /dev/null +++ b/test/vuex/acc-one-approve-po/store.js @@ -0,0 +1,14 @@ +// import manager from "./modules/manager.js"; +// import prkacab from "./modules/prkacab.js" +import system from "../../../apps/modules/system/system.js"; +import po from "./modules/po.js"; + +export const store = new Vuex.Store({ + modules: { + po: po, + system: system + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-cashier-v2/api/cashier.js b/test/vuex/acc-one-cashier-v2/api/cashier.js new file mode 100644 index 0000000..9f6f47f --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/api/cashier.js @@ -0,0 +1,401 @@ +const URL = "/one-api/mockup/purchase/cashier/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirectRealitation/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchBranch(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getbranch',{ + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchAccDana(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getcoa', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchAccBiaya(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getcoa', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchAccTemp(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getcoa', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getPurchase(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/getPurchase", { + token: token, + branchcode: prm, + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchdetail(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirectRealitation/searchdetail", { + token: token, + ID: prm, + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveDetail(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/save", { + token: token, + BranchCode: prm.branch, + CoaSourceID: prm.accountDana, + CoaExpenseID: prm.accountBiaya, + CoaTemporaryID: prm.accountTemp, + total: prm.total, + details: prm.details + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getTotalDraft(token) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirectRealitation/getTotalDraft', { + token: token + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getTotalPaid(token) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirectRealitation/getTotalPaid', { + token: token + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteVoucher(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/delete', { + token: token, + ID: prm.PVID + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editVoucher(prm) { + try { + // console.log(prm) + var resp = await axios.post(URL + "purchaseRequestDirectRealitation/update",prm); + // console.log(resp) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updatepaid(prm) { + try { + // console.log(prm) + var resp = await axios.post(URL + "purchaseRequestDirectRealitation/updatepaid", prm); + console.log('api resp',resp) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getPurchaseUpdateNew(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/getPurchaseUpdateNew", { + token: token, + branchcode: prm.branchcode, + ID: prm.voucherID + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getUserReceive(prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirectRealitation/getUserReceive", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getVoucherDetail(params) { + try { + var resp = await axios.post(URL + "purchaseRequestDirectRealitation/getVoucherDetail", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveVoucherDetail(params) { + try { + var resp = await axios.post(URL + "purchaseRequestDirectRealitation/saveVoucherDetail", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + + let data = resp.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function editVoucherV2(prm) { + try { + // console.log(prm) + var resp = await axios.post(URL + "purchaseRequestDirectRealitation/updateV2",prm); + // console.log(resp) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/components/cashierListing.vue b/test/vuex/acc-one-cashier-v2/components/cashierListing.vue new file mode 100644 index 0000000..e8d331a --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/components/cashierListing.vue @@ -0,0 +1,700 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/components/dialogForm.vue b/test/vuex/acc-one-cashier-v2/components/dialogForm.vue new file mode 100644 index 0000000..f5c50d4 --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/components/dialogForm.vue @@ -0,0 +1,682 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/components/dialogFormPay.vue b/test/vuex/acc-one-cashier-v2/components/dialogFormPay.vue new file mode 100644 index 0000000..ba0b34b --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/components/dialogFormPay.vue @@ -0,0 +1,649 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/components/dialogFormRealise.vue b/test/vuex/acc-one-cashier-v2/components/dialogFormRealise.vue new file mode 100644 index 0000000..577ff02 --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/components/dialogFormRealise.vue @@ -0,0 +1,392 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/components/dialogItemRealize.vue b/test/vuex/acc-one-cashier-v2/components/dialogItemRealize.vue new file mode 100644 index 0000000..c5ed786 --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/components/dialogItemRealize.vue @@ -0,0 +1,136 @@ + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/components/dialogViewImg.vue b/test/vuex/acc-one-cashier-v2/components/dialogViewImg.vue new file mode 100644 index 0000000..b1b8b57 --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/components/dialogViewImg.vue @@ -0,0 +1,62 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/components/listingDetail.vue b/test/vuex/acc-one-cashier-v2/components/listingDetail.vue new file mode 100644 index 0000000..9aada00 --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/components/listingDetail.vue @@ -0,0 +1,208 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/index.php b/test/vuex/acc-one-cashier-v2/index.php new file mode 100644 index 0000000..598f200 --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/index.php @@ -0,0 +1,71 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-cashier-v2/modules/cashier.js b/test/vuex/acc-one-cashier-v2/modules/cashier.js new file mode 100644 index 0000000..4f6fc06 --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/modules/cashier.js @@ -0,0 +1,790 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/cashier.js"; + +export default { + namespaced: true, + state: { + dialog_cashier: false, + status_options: [ + { val: 0, text: 'All' }, { val: 1, text: 'Draft' }, + { val: 2, text: 'Paid' }, { val: 3, text: 'Realitation' } + ], + selected_status: { val: 1, text: 'Draft' }, + menuStartDate: false, + menuEndDate: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + xStartDate: moment(new Date()).format('YYYY-MM-DD'), + xEndDate: moment(new Date()).format('YYYY-MM-DD'), + + // listing + currentPage: 1, + search_status: 0, + search_error_message: "", + cashierList: [], + selected_cashier: {}, + total_page_cashier: 0, + xsearch: "", + act: "new", + imagePreviews: [], + imagePrevPaid: [], + + // form + load_status_branch: 0, + error_message: "", + alert_error: false, + branchList: [], + selected_branch: {}, + search_branch: "", + accountDanaList: [], + selected_accountDana: {}, + search_accountDana: "", + load_status_accDana: 0, + accountBiayaList: [], + selected_accountBiaya: {}, + search_accountBiaya: "", + load_status_accBiaya: 0, + accountTempList: [], + selected_accountTemp: {}, + search_accountTemp: "", + load_status_accTemp: 0, + load_status: 0, + purchaseList: [], + selected_purchase: [], + resume_total: {"totalRealitation": 0}, + errors: [], + alert_error: false, + alert_success: false, + success_message: "", + totalDraft: 0, + + // detail + search_status_detail: 0, + details: [], + show_progrees_upload: false, + note: "", + notepay: "", + dialog_cashier_pay: false, + totalPaid: 0, + restPrice: 0, + openprint: false, + numberRequest: [], + total_akhir: 0, + requestDescription: "", + status: '', + xdate: '', + imagePayPreviews: [], + imagePayFiles: [], + user: one_user(), + userReceive: [], + selected_userReceive:'', + imageRelationPreviews: [], + imageRelationFiles: [], + + // voucher detail + dialog_view_img: false, + listing_item_realise: [], + selected_img_view: '' + }, + mutations: { + update_dialog_cashier(state, val) { + state.dialog_cashier = val; + }, + update_status_options(state, val) { + state.status_options = val; + }, + update_selected_status(state, val) { + state.selected_status = val; + }, + update_menuStartDate(state, val) { + state.menuStartDate = val; + }, + update_menuEndDate(state, val) { + state.menuEndDate = val; + }, + update_dStartDate(state, val) { + state.dStartDate = val; + }, + update_dEndDate(state, val) { + state.dEndDate = val; + }, + update_xStartDate(state, val) { + state.xStartDate = val; + }, + update_xEndDate(state, val) { + state.xEndDate = val; + }, + update_currentPage(state, val) { + state.currentPage = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_cashierList(state, val) { + state.cashierList = val; + }, + update_selected_cashier(state, val) { + state.selected_cashier = val; + }, + update_total_page_cashier(state, val) { + state.total_page_cashier = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.currentPage = 1; + }, + update_act(state, val) { + state.act = val + }, + update_load_status_branch(state, val) { + state.load_status_branch = val; + }, + update_error_message(state, val) { + state.error_message = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_branchList(state, val) { + state.branchList = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_search_branch(state, val) { + state.search_branch = val; + }, + update_accountDanaList(state, val) { + state.accountDanaList = val; + }, + update_selected_accountDana(state, val) { + state.selected_accountDana = val; + }, + update_search_accountDana(state, val) { + state.search_accountDana = val; + }, + update_load_status_accDana(state, val) { + state.load_status_accDana = val; + }, + update_accountBiayaList(state, val) { + state.accountBiayaList = val; + }, + update_selected_accountBiaya(state, val) { + state.selected_accountBiaya = val; + }, + update_search_accountBiaya(state, val) { + state.search_accountBiaya = val; + }, + update_load_status_accBiaya(state, val) { + state.load_status_accBiaya = val; + }, + update_accountTempList(state, val) { + state.accountTempList = val; + }, + update_selected_accountTemp(state, val) { + state.selected_accountTemp = val; + }, + update_search_accountTemp(state, val) { + state.search_accountTemp = val; + }, + update_load_status_accTemp(state, val) { + state.load_status_accTemp = val; + }, + update_load_status(state, val) { + state.load_status = val; + }, + update_purchaseList(state, val) { + state.purchaseList = val; + }, + update_selected_purchase(state, val) { + state.selected_purchase = val; + }, + update_resume_total(state, val) { + state.resume_total = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_success_message(state, val) { + state.success_message = val; + }, + update_totalDraft(state, val) { + state.totalDraft = val + }, + update_search_status_detail(state, val) { + state.search_status_detail = val; + }, + update_details(state, val) { + state.details = val + }, + update_show_progrees_upload(state, val) { + state.show_progrees_upload = val + }, + update_note(state, val) { + state.note = val + }, + update_notepay(state, val) { + state.notepay = val + }, + update_dialog_cashier_pay(state, val) { + state.dialog_cashier_pay = val + }, + update_totalPaid(state, val) { + state.totalPaid = val + }, + update_restPrice(state, val) { + state.restPrice = val + }, + update_openprint(state, val) { + state.openprint = val + }, + update_imagePreviews(state, val) { + state.imagePreviews = val + }, + update_imagePrevPaid(state, val) { + state.imagePrevPaid = val + }, + update_numberRequest(state, val) { + state.numberRequest = val + }, + update_total_akhir(state, val) { + state.total_akhir = val + }, + update_requestDescription(state, val) { + state.requestDescription = val + }, + update_status(state, val) { + state.status = val + }, + update_xdate(state, val) { + state.xdate = val + }, + update_imagePayPreviews(state, val) { + state.imagePayPreviews = val; + }, + update_imagePayFiles(state, val) { + state.imagePayFiles = val; + }, + update_user(state, val) { + state.user = val; + }, + update_userReceive(state, val) { + state.userReceive = val; + }, + update_selected_userReceive(state, val) { + state.selected_userReceive = val; + }, + update_imageRelationPreviews(state, val) { + state.imageRelationPreviews = val; + }, + update_imageRelationFiles(state, val) { + state.imageRelationFiles = val; + }, + update_dialog_view_img(state, val) { + state.dialog_view_img = val + }, + update_listing_item_realise(state, val) { + state.listing_item_realise = val + }, + update_selected_img_view(state, val) { + state.selected_img_view = val + } + }, + actions: { + async search(context) { + context.commit("update_search_status", 1); + + try { + var url_string = window.location.href + var url = new URL(url_string); + var status = url.searchParams.get("status"); + var xstartdate = url.searchParams.get("startdate"); + + context.commit("update_status", status); + context.commit("update_xdate", xstartdate); + + const today = moment(new Date()).format('YYYY-MM-DD'); + + var startDate = xstartdate == null || xstartdate == '' ? context.state.xStartDate : xstartdate; + var endDate = xstartdate == null || xstartdate == '' ? context.state.xEndDate : today; + + var prm = { + token: one_token(), + currentPage: context.state.currentPage, + status: status == null || status == '' ? context.state.selected_status.text : status, + search: context.state.xsearch, + startdate: startDate, + enddate: endDate, + lastId: -1, + }; + + let resp = await api.search(prm); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total, + }; + + context.commit("update_cashierList", data.records); + context.commit("update_total_page_cashier", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async searchBranch(context, prm) { + context.commit("update_load_status_branch", 1) + try { + let resp = await api.searchBranch(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status_branch", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status_branch", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_branchList", data.records) + } + } catch (e) { + context.commit("update_load_status_branch", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async searchAccDana(context, prm) { + context.commit("update_load_status_accDana", 1) + try { + let resp = await api.searchAccDana(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status_accDana", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status_accDana", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_accountDanaList", data.records) + } + } catch (e) { + context.commit("update_load_status_accDana", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async searchAccBiaya(context, prm) { + context.commit("update_load_status_accBiaya", 1) + try { + let resp = await api.searchAccBiaya(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status_accBiaya", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status_accBiaya", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_accountBiayaList", data.records) + } + } catch (e) { + context.commit("update_load_status_accBiaya", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async searchAccTemp(context, prm) { + context.commit("update_load_status_accTemp", 1) + try { + let resp = await api.searchAccTemp(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status_accTemp", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status_accTemp", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_accountTempList", data.records) + } + } catch (e) { + context.commit("update_load_status_accTemp", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getPurchase(context, prm) { + context.commit("update_load_status", 1) + try { + let resp = await api.getPurchase(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_purchaseList", data.records) + } + } catch (e) { + context.commit("update_load_status", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async searchdetail(context, prm) { + context.commit("update_search_status_detail", 1) + try { + let resp = await api.searchdetail(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status_detail", 3) + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status_detail", 2) + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records + } + + let total = 0; + data.records.forEach(element => { + total = total + Number(element.realised_price) + }); + + context.commit("update_details", data.records) + context.commit("update_restPrice", total) + } + } catch (e) { + context.commit("update_search_status_detail", 3) + context.commit("update_search_error_message", e.message); + } + }, + + async save(context, prm) { + context.commit("update_search_status_detail", 1) + try { + + let resp = await api.saveDetail(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_search_status_detail", 2) + context.commit("update_error_message", resp.message); + + let data = { + records: resp.data.records + } + + context.commit("update_alert_success", true); + context.commit("update_dialog_cashier", false); + var msg = `Sukses menyimpan data baru dengan kode ${data.records[0].PaymentVoucherNumber}`; + context.commit("update_success_message", msg); + context.commit("update_selected_cashier", data.records[0]); + context.dispatch("search"); + context.dispatch("searchdetail", data.records[0].PaymentVoucherID); + } + } catch (e) { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getTotalDraft(context, prm) { + context.commit("update_search_status", 1) + try { + let resp = await api.getTotalDraft(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_error_message", resp.message); + } else { + context.commit("update_search_status", 2) + context.commit("update_error_message", ""); + let data = { + total: resp.data.total + } + + context.commit("update_totalDraft", data.total) + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_error_message", e.message); + } + }, + + async getTotalPaid(context, prm) { + context.commit("update_search_status", 1) + try { + let resp = await api.getTotalPaid(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_error_message", resp.message); + } else { + context.commit("update_search_status", 2) + context.commit("update_error_message", ""); + let data = { + total: resp.data.total + } + + context.commit("update_totalPaid", data.total) + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_error_message", e.message); + } + }, + + async delete(context, prm) { + context.commit("update_search_status", 1) + try { + + let resp = await api.deleteVoucher(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_search_status", 2) + context.commit("update_error_message", resp.message); + + let data = { + records: resp.data.records + } + + context.commit("update_alert_success", true); + context.commit("update_dialog_cashier", false); + var msg = `Sukses menghapus data dengan kode ` + prm.PVNumber; + context.commit("update_success_message", msg); + // context.commit("update_selected_cashier", data.records[0]); + context.dispatch("search"); + context.dispatch("searchdetail", ""); + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async update(context, prm) { + context.commit("update_search_status_detail", 1) + try { + + let resp = await api.editVoucherV2(prm) + if (resp.status != "OK") { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_search_status_detail", 2) + context.commit("update_error_message", resp.message); + + let data = { + records: resp.data.records + } + + context.commit("update_note", ""); + context.commit("update_restPrice", 0); + context.commit("update_total_akhir", 0); + context.commit("update_imageRelationPreviews", []); + context.commit("update_imageRelationFiles", []); + context.commit("update_alert_success", true); + context.commit("update_dialog_cashier", false); + var msg = `Sukses Realisasi dengan kode ${data.records[0].PaymentVoucherNumber}`; + context.commit("update_success_message", msg); + // context.commit("update_selected_cashier", data.records[0]); + context.dispatch("search"); + // context.dispatch("searchdetail", data.records[0].PaymentVoucherID); + } + } catch (e) { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async updatepaid(context, prm) { + context.commit("update_search_status_detail", 1) + try { + + let resp = await api.updatepaid(prm) + console.log("updatepaid resp", resp) + if (resp.status != "OK") { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_search_status_detail", 2) + context.commit("update_error_message", resp.message); + + let data = { + records: resp.data.records + } + + context.commit("update_notepay", ""); + context.commit("update_imagePayPreviews", []); + context.commit("update_imagePayFiles", []); + context.commit("update_selected_userReceive", ''); + context.commit("update_alert_success", true); + context.commit("update_dialog_cashier_pay", false); + var msg = `Sukses Pembayaran dengan kode ${data.records[0].PaymentVoucherNumber}`; + context.commit("update_success_message", msg); + // context.commit("update_selected_cashier", data.records[0]); + context.dispatch("search"); + // context.dispatch("searchdetail", data.records[0].PaymentVoucherID); + } + } catch (e) { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getPurchaseUpdateNew(context, prm) { + context.commit("update_load_status", 1) + try { + let resp = await api.getPurchaseUpdateNew(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_purchaseList", data.records) + } + } catch (e) { + context.commit("update_load_status", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getUserReceive(context) { + context.commit("update_load_status", 1) + try { + let prm = { + token: one_token(), + userId: context.state.user.M_UserID, + } + let resp = await api.getUserReceive(prm) + if (resp.status != "OK") { + context.commit("update_load_status", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_userReceive", data.records) + } + } catch (e) { + context.commit("update_load_status", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getVoucherDetail(context) { + try { + let param = { + token: one_token(), + ID: context.state.selected_cashier.PaymentVoucherID + } + let resp = await api.getVoucherDetail(param) + if (resp.status != 'OK') { + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + let data = resp.data + + context.commit("update_listing_item_realise", data) + + let realised = data.reduce((sum, item) => sum + Number(item.estimate_price), 0); + let detail = context.state.details; + let adjustment = detail.reduce((sum, item) => sum + Number(item.PurchaseRequestDirectAdjustment), 0) + + let total = Number(context.state.selected_cashier.PaymentVoucherTotal) + let sisa = (total + adjustment) - realised + context.commit("update_total_akhir", sisa) + } + } catch (error) { + context.commit("update_error_message", error.message); + context.commit("update_alert_error", true); + } + }, + + async saveVoucherDetail(context, param) { + try { + param.token = one_token() + let resp = await api.saveVoucherDetail(param) + if (resp.status != 'OK') { + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_alert_success", true); + context.commit("update_success_message", "Success"); + + let ID = context.state.selected_cashier.PaymentVoucherID; + context.dispatch("searchdetail", ID) + context.commit("update_dialog_realise_item", false); + context.commit("update_listing_item_realise", []) + } + + } catch (error) { + context.commit("update_error_message", error.message); + context.commit("update_alert_error", true); + } + } + }, +}; + diff --git a/test/vuex/acc-one-cashier-v2/store.js b/test/vuex/acc-one-cashier-v2/store.js new file mode 100644 index 0000000..f0479e4 --- /dev/null +++ b/test/vuex/acc-one-cashier-v2/store.js @@ -0,0 +1,11 @@ +import cashier from "./modules/cashier.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + cashier: cashier, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-fixed-asset/api/fixedasset.js b/test/vuex/acc-one-fixed-asset/api/fixedasset.js new file mode 100644 index 0000000..1a2277e --- /dev/null +++ b/test/vuex/acc-one-fixed-asset/api/fixedasset.js @@ -0,0 +1,192 @@ +const URL = "/one-api/fixedasset/item"; + +export async function getAcAccumDepre(prm) { + try { + var resp = await axios.post(URL + '/getAcAccumDepre', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAcCoa(prm) { + try { + var resp = await axios.post(URL + '/getAcCoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getItem(prm) { + try { + var resp = await axios.post(URL + '/getItem', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getDepartment(prm) { + try { + var resp = await axios.post(URL + '/getDepartment', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getPresentase(prm) { + try { + var resp = await axios.post(URL + '/getPresentase', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search(prm) { + try { + var resp = await axios.post(URL + "/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function addData(prm) { + try { + var resp = await axios.post(URL + '/addData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getByID(prm) { + try { + var resp = await axios.post(URL + '/get_by_id', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editData(prm) { + try { + var resp = await axios.post(URL + '/editData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteData(prm) { + try { + var resp = await axios.post(URL + '/deleteData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-fixed-asset/components/FixedAsset.vue b/test/vuex/acc-one-fixed-asset/components/FixedAsset.vue new file mode 100644 index 0000000..b7d5235 --- /dev/null +++ b/test/vuex/acc-one-fixed-asset/components/FixedAsset.vue @@ -0,0 +1,1147 @@ + + + + + diff --git a/test/vuex/acc-one-fixed-asset/index.php b/test/vuex/acc-one-fixed-asset/index.php new file mode 100644 index 0000000..c898d06 --- /dev/null +++ b/test/vuex/acc-one-fixed-asset/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-fixed-asset/modules/fixedasset.js b/test/vuex/acc-one-fixed-asset/modules/fixedasset.js new file mode 100644 index 0000000..e89ef89 --- /dev/null +++ b/test/vuex/acc-one-fixed-asset/modules/fixedasset.js @@ -0,0 +1,671 @@ +import * as api from "../api/fixedasset.js" + +export default { + namespaced: true, + state: { + Fa_ClassID: 0, + a_coas: [], + a_msg_info: '', + a_open_dialog_info: false, + a_save_status: 0, + // search table + a_x_search: '', + a_current_page: 1, + a_last_id: -1, + a_total_coa: 0, + // search table + a_selected_a_coa: {}, + a_search_status: 0, + a_alert_success: false, + a_msg_success: '', + a_alert_error: false, + a_save_error_message: '', + dialog_add_coa: false, + dialog_edit_coa: false, + e_loading_nat_group: false, + // text classname + a_faname: '', + e_classname: '', + // ac coa + a_loading_coa: false, + a_coa_list: [], + a_coa: {}, + a_coa_search: '', + + // ac item + a_loading_item: false, + a_item_list: [], + a_item: {}, + a_item_search: '', + + // ac department + a_loading_department: false, + a_department_list: [], + a_department: {}, + a_department_search: '', + // ac presentase + a_loading_presentase: false, + a_presentase_list: [], + a_presentase: {}, + a_presentase_search: '', + a_inventaris : '', + a_note : '', + a_fa_account_id: 0, + a_fa_account_name: '', + a_accum_depre_account_id: 0, + a_accum_depre_account_name: '', + a_depre_account_id: 0, + a_depre_account_name: '', + a_qty: 1, + a_acquisition_price: 0, + a_book_value: 0, + + // text note + a_note: '', + e_note: '', + a_errors_save: [], + Fa_ClassID: 0, + a_errors_save_coa: [], + xid: 0, + xnumber: '', + errors: [], + a_fa_age: 0, + a_fa_depresiasi_bulan: 0, + branchOptions: [], + regionalOptions: [], + xRegional: "", + xBranch: "" + }, + mutations: { + updateBranchOptions(state, val) { + state.branchOptions = val; + }, + + updateRegionalOptions(state, val) { + state.regionalOptions = val; + }, + updateXRegional(state, val) { + state.xRegional = val; + }, + updateXBranch(state, val) { + state.xBranch = val; + }, + update_a_fa_age(state, val) { + state.a_fa_age = val; + }, + update_a_fa_depresiasi_bulan(state, val) { + state.a_fa_depresiasi_bulan = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_xid(state, val) { + state.xid = val + }, + update_xnumber(state, val) { + state.xnumber = val + }, + update_a_errors_save_coa(state, val) { + state.a_errors_save_coa = val + }, + update_a_selected_a_coa(state, val) { + state.a_selected_a_coa = val + }, + update_e_loading_nat_group(state, val) { + state.e_loading_nat_group = val + }, + update_a_errors_save(state, val) { + state.a_errors_save = val + }, + update_a_save_error_message(state, val) { + state.a_save_error_message = val + }, + update_a_alert_error(state, val) { + state.a_alert_error = val + }, + update_a_msg_success(state, val) { + state.a_msg_success = val + }, + update_a_msg_info(state, val) { + state.a_msg_info = val + }, + update_a_open_dialog_info(state, val) { + state.a_open_dialog_info = val + }, + update_a_alert_success(state, val) { + state.a_alert_success = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + //table + update_a_search_error_message(state, val) { + state.a_search_error_message = val + }, + update_a_search_status(state, val) { + state.a_search_status = val + }, + update_a_x_search(state, val) { + state.a_x_search = val + }, + update_a_current_page(state, val) { + state.a_current_page = val + }, + update_a_last_id(state, val) { + state.a_last_id = val + }, + update_a_total_coa(state, val) { + state.a_total_coa = val + }, + update_a_a_coas(state, val) { + state.a_coas = val + }, + // text classname + update_a_faname(state, val) { + state.a_faname = val + }, + update_e_classname(state, val) { + state.e_classname = val + }, + // ac coa + update_a_loading_coa(state, val) { + state.a_loading_coa = val + }, + update_e_loading_coa(state, val) { + state.e_loading_coa = val + }, + update_a_coa_list(state, val) { + state.a_coa_list = val + }, + update_e_coa_list(state, val) { + state.e_coa_list = val + }, + update_a_coa(state, val) { + state.a_coa = val + }, + update_e_coa(state, val) { + state.e_coa = val + }, + update_a_coa_search(state, val) { + state.a_coa_search = val + }, + update_e_coa_search(state, val) { + state.e_coa_search = val + }, + // ac item + update_a_loading_item(state, val) { + state.a_loading_item = val + }, + update_a_item_list(state, val) { + state.a_item_list = val + }, + update_a_item(state, val) { + state.a_item = val + }, + update_a_item_search(state, val) { + state.a_item_search = val + }, + // ac department + update_a_loading_department(state, val) { + state.a_loading_department = val + }, + update_a_department_list(state, val) { + state.a_department_list = val + }, + update_a_department(state, val) { + state.a_department = val + }, + update_a_department_search(state, val) { + state.a_department_search = val + }, + // ac presentase + update_a_loading_presentase(state, val) { + state.a_loading_presentase = val + }, + update_a_presentase_list(state, val) { + state.a_presentase_list = val + }, + update_a_presentase(state, val) { + state.a_presentase = val + }, + update_a_presentase_search(state, val) { + state.a_presentase_search = val + }, + update_a_inventaris(state, val) { + state.a_inventaris = val + }, + update_a_note(state, val) { + state.a_note = val + }, + update_a_fa_account_id(state, val) { + state.a_fa_account_id = val + }, + update_a_fa_account_name(state, val) { + state.a_fa_account_name = val + }, + update_a_accum_depre_account_id(state, val) { + state.a_accum_depre_account_id = val + }, + update_a_accum_depre_account_name(state, val) { + state.a_accum_depre_account_name = val + }, + update_a_depre_account_id(state, val) { + state.a_depre_account_id = val + }, + update_a_depre_account_name(state, val) { + state.a_depre_account_name = val + }, + update_a_qty(state, val) { + state.a_qty = val + }, + update_a_acquisition_price(state, val) { + state.a_acquisition_price = val + }, + update_a_book_value(state, val) { + state.a_book_value = val + }, + // text note + update_a_note(state, val) { + state.a_note = val + }, + update_e_note(state, val) { + state.e_note = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + update_dialog_edit_coa(state, val) { + state.dialog_edit_coa = val + }, + update_Fa_ClassID(state, val) { + state.Fa_ClassID = val + }, + update_a_save_status(state, val) { + state.a_save_status = val + }, + }, + actions: { + // search + async search(context, prm) { + context.commit("update_a_search_status", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", resp.message) + context.commit("update_a_msg_info", resp.message) + context.commit("update_a_open_dialog_info", true) + } else { + context.commit("update_a_search_status", 2) + context.commit("update_a_search_error_message", "") + context.commit("update_a_msg_info", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_a_a_coas", data.records) + context.commit("update_a_total_coa", data.total) + } + } catch (e) { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", e.message) + context.commit("update_a_msg_info", e.message) + context.commit("update_a_open_dialog_info", true) + } + }, + + // get ac coa from api + async open_add_coa(context, payload) { + context.commit("update_a_loading_coa", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcCoa(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa", false) + context.commit("update_a_coa_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa", false) + } + }, + + + async open_add_item(context, payload) { + context.commit("update_a_loading_item", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getItem(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_item", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_item", false) + context.commit("update_a_item_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_item", false) + } + }, + async open_add_department(context, payload) { + context.commit("update_a_loading_department", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getDepartment(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_department", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_department", false) + context.commit("update_a_department_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_department", false) + } + }, + async open_add_presentase(context, payload) { + context.commit("update_a_loading_presentase", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getPresentase(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_presentase", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_presentase", false) + context.commit("update_a_presentase_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_presentase", false) + } + }, + // add data + async add_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + + let resp = await api.addData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Add Data Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_add_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + + context.commit("fixedasset/update_dialog_add_coa", false); + context.commit("fixedasset/update_a_faname", ""); + context.commit("fixedasset/update_a_coa", {}); + context.commit("fixedasset/update_a_deprecorp", ""); + context.commit("fixedasset/update_a_coa_accum_depre", {}); + context.commit("fixedasset/update_a_note", ""); + } else { + context.commit("update_a_errors_save", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + + // get_by_id + async get_by_id(context, payload) { + context.commit("update_e_loading_nat_group", true) + try { + let prm = {}; + prm.token = one_token() + // fa_class + prm.Fa_ClassID = payload.Fa_ClassID + // coa + prm.Fa_ClassCoaID = payload.Fa_ClassCoaID + // accum depre + prm.Fa_ClassAccumDepreCoaID = payload.Fa_ClassAccumDepreCoaID + + let resp = await api.getByID(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_nat_group", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_nat_group", true) + + // MapNatGroup_ID + context.commit("update_Fa_ClassID", resp.data.record_fa_class[0].Fa_ClassID) + + // coa + context.commit("update_e_coa_list", resp.data.records_coa) + context.commit("update_e_coa", { + coaID: resp.data.records_coa[0].coaID, + coaAccountNo: resp.data.records_coa[0].coaAccountNo, + coaDescription: resp.data.records_coa[0].coaDescription, + coaSubDescription: resp.data.records_coa[0].coaSubDescription, + coaAccountType: resp.data.records_coa[0].coaAccountType, + coaSpecialAccountType: resp.data.records_coa[0].coaSpecialAccountType, + coaIsInput: resp.data.records_coa[0].coaIsInput, + coaReportSchedule: resp.data.records_coa[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_coa[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_coa[0].coaCashFlowCategory, + coaCreated: resp.data.records_coa[0].coaCreated, + coaLastUpdated: resp.data.records_coa[0].coaLastUpdated, + coaIsActive: resp.data.records_coa[0].coaIsActive, + coaLevel: resp.data.records_coa[0].coaLevel + }) + + // accum depre + context.commit("update_e_coa_accum_depre_list", resp.data.records_accum_depre) + context.commit("update_e_coa_accum_depre", { + coaID: resp.data.records_accum_depre[0].coaID, + coaAccountNo: resp.data.records_accum_depre[0].coaAccountNo, + coaDescription: resp.data.records_accum_depre[0].coaDescription, + coaSubDescription: resp.data.records_accum_depre[0].coaSubDescription, + coaAccountType: resp.data.records_accum_depre[0].coaAccountType, + coaSpecialAccountType: resp.data.records_accum_depre[0].coaSpecialAccountType, + coaIsInput: resp.data.records_accum_depre[0].coaIsInput, + coaReportSchedule: resp.data.records_accum_depre[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_accum_depre[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_accum_depre[0].coaCashFlowCategory, + coaCreated: resp.data.records_accum_depre[0].coaCreated, + coaLastUpdated: resp.data.records_accum_depre[0].coaLastUpdated, + coaIsActive: resp.data.records_accum_depre[0].coaIsActive, + coaLevel: resp.data.records_accum_depre[0].coaLevel + }) + + // fa classname + context.commit("update_e_classname", resp.data.record_fa_class[0].Fa_ClassName) + + // note + context.commit("update_e_note", resp.data.record_fa_class[0].Fa_ClassAccumNote) + + // depre corp + context.commit("update_e_deprecorp", resp.data.record_fa_class[0].Fa_ClassDepreCorp) + + context.commit("update_dialog_edit_coa", true) + } + } catch (e) { + context.commit("update_e_loading_nat_group", false) + } + }, + + // get ac coa from api + async open_edit_coa(context, payload) { + context.commit("update_e_loading_coa", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcCoa(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa", false) + context.commit("update_e_coa_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa", false) + } + }, + + // get ac coa accum depre from api + async open_edit_coa_accum_depre(context, payload) { + context.commit("update_e_loading_coa_accum_depre", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcAccumDepre(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa_accum_depre", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa_accum_depre", false) + context.commit("update_e_coa_accum_depre_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa_accum_depre", false) + } + }, + async regional(context) { + let response = await api.getRegional({ token: one_token() }); + if (response.status === "OK") { + let data = { + records: response.data.records, + }; + + context.commit("updateRegionalOptions", data.records); + } + }, + async branch(context) { + let response = await api.getBranch({ token: one_token() }); + if (response.status === "OK") { + let data = { + records: response.data.records, + }; + + context.commit("updateBranchOptions", data.records); + } + }, + + // edit data + async edit_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + + let resp = await api.editData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Edit Data Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_add_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + + context.commit("fixedasset/update_dialog_add_coa", false); + context.commit("fixedasset/update_a_faname", ""); + context.commit("fixedasset/update_a_coa", {}); + context.commit("fixedasset/update_a_deprecorp", ""); + context.commit("fixedasset/update_a_coa_accum_depre", {}); + context.commit("fixedasset/update_a_note", ""); + } else { + context.commit("update_a_errors_save", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + // delete data + async delete_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteData(prm) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Coa " + prm.delete_data + " berhasil dihapus" + context.commit("update_a_msg_success", msg) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + }, +} \ No newline at end of file diff --git a/test/vuex/acc-one-fixed-asset/store.js b/test/vuex/acc-one-fixed-asset/store.js new file mode 100644 index 0000000..c35e534 --- /dev/null +++ b/test/vuex/acc-one-fixed-asset/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import fixedasset from "./modules/fixedasset.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + fixedasset:fixedasset, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-item-out-v3/api/api-requester.js b/test/vuex/acc-one-item-out-v3/api/api-requester.js new file mode 100644 index 0000000..04b9293 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/api/api-requester.js @@ -0,0 +1,559 @@ +const URL = "/one-api/mockup/itemout/"; + +export async function search(prm) { + try { + var response = await axios.post(URL + "itemoutv3/search", prm); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchDetail(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/searchDetail", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveRequest(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/saveRequest", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateRequest(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/updateRequest", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteRequest(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/deleteRequest", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveDetail(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/saveDetail", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateDetail(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/updateDetail", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteDetail(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/deleteDetail", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getWarehouse(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/getWarehouse", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getDepartment(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/getDepartment", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchItem(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/searchItem', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUnit(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/getUnit', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function orderConfirm(prm) { + try { + var response = await axios.post( + URL + "itemoutv3/orderConfirm", + prm + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function listrequestitem(prm) { + try { + var response = await axios.post(URL + "itemoutv3/listrequest", prm); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getDivisionUser(payload) { + try { + var response = await axios.post(URL + "RequestItemOut/getDivisionUser", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approveRequest(prm) { + try { + var response = await axios.post(URL + "itemoutv3/approveRequest", prm); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function rejectedRequest(prm) { + try { + var response = await axios.post(URL + "itemoutv3/rejectedRequest", prm); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getDivisionByUser(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/getDivisionByUser', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getItemRequest(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/getItemRequest', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getDetailItemOut(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/getDetailItemOut', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getItemOuts(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/getItemOuts', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function confirmIO(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/confirmIO', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function approveIO(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/approveIO', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function processIO(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/processIO', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function rejectRequest(prm) { + try { + var resp = await axios.post(URL + 'itemoutv3/rejectRequest', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getItemBatchListing(params) { + try { + var resp = await axios.post(URL + "itemoutv3/getItemBatchListing", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.message + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getlevel(prm) { + try { + var resp = await axios.post(URL + "itemoutv3/getlevel", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-item-out-v3/components/addItemDetailDialog.vue b/test/vuex/acc-one-item-out-v3/components/addItemDetailDialog.vue new file mode 100644 index 0000000..6cd51e7 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/addItemDetailDialog.vue @@ -0,0 +1,324 @@ + + + + + diff --git a/test/vuex/acc-one-item-out-v3/components/addItemOutDialog.vue b/test/vuex/acc-one-item-out-v3/components/addItemOutDialog.vue new file mode 100644 index 0000000..e61fc70 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/addItemOutDialog.vue @@ -0,0 +1,917 @@ + + + diff --git a/test/vuex/acc-one-item-out-v3/components/dialogBatch.vue b/test/vuex/acc-one-item-out-v3/components/dialogBatch.vue new file mode 100644 index 0000000..ba03c34 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/dialogBatch.vue @@ -0,0 +1,307 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-out-v3/components/dialogItemApprove.vue b/test/vuex/acc-one-item-out-v3/components/dialogItemApprove.vue new file mode 100644 index 0000000..6a3d28f --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/dialogItemApprove.vue @@ -0,0 +1,288 @@ + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-out-v3/components/dialogItemConfirm.vue b/test/vuex/acc-one-item-out-v3/components/dialogItemConfirm.vue new file mode 100644 index 0000000..b999cce --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/dialogItemConfirm.vue @@ -0,0 +1,272 @@ + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-out-v3/components/dialogItemPreview.vue b/test/vuex/acc-one-item-out-v3/components/dialogItemPreview.vue new file mode 100644 index 0000000..465c74c --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/dialogItemPreview.vue @@ -0,0 +1,237 @@ + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-out-v3/components/dialogItemProcess.vue b/test/vuex/acc-one-item-out-v3/components/dialogItemProcess.vue new file mode 100644 index 0000000..0d6c580 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/dialogItemProcess.vue @@ -0,0 +1,274 @@ + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-out-v3/components/requestItemOut.vue b/test/vuex/acc-one-item-out-v3/components/requestItemOut.vue new file mode 100644 index 0000000..c836344 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/requestItemOut.vue @@ -0,0 +1,888 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-out-v3/components/requestListing.vue b/test/vuex/acc-one-item-out-v3/components/requestListing.vue new file mode 100644 index 0000000..b9c54f0 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/components/requestListing.vue @@ -0,0 +1,956 @@ + + + + + diff --git a/test/vuex/acc-one-item-out-v3/index.php b/test/vuex/acc-one-item-out-v3/index.php new file mode 100644 index 0000000..d8fba16 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/index.php @@ -0,0 +1,71 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-out-v3/modules/listrequest.js b/test/vuex/acc-one-item-out-v3/modules/listrequest.js new file mode 100644 index 0000000..714e182 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/modules/listrequest.js @@ -0,0 +1,266 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api-requester.js"; + +export default { + namespaced: true, + state: { + request: [], + selectedRequest: [], + totalPage: 0, + currentPage: 1, + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + menuStartDate: false, + menuEndDate: false, + + statusOptions: [ + { value: '', title: "All" }, + { value: 'Draft', title: "Draft" }, + { value: 'Send Request', title: "Send Request" }, + { value: 'Process', title: "Process" }, + { value: 'Rejected', title: "Rejected" }, + { value: 'Partial', title: "Partial" }, + { value: 'Completed', title: "Completed" }, + ], + fStatus: {value: "", title: "All"}, + fSearch: "", + lastId: -1, + loadingStatus: 0, + errorMessage: "", + selectedItems: [], + selectedItem: {}, + opendialoginfo: false, + msginfo: "", + loadingSave: false, + errMessage: "", + alertError: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + dialogapprove: false, + msgapprove: '', + dialogreject: false, + msgreject: '', + approveDivisionUserID: 0, + approveDivision: '', + }, + mutations: { + update_request(state, val) { + state.request = val + }, + update_selectedRequest(state, val) { + state.selectedRequest = val + }, + update_totalPage(state, val) { + state.totalPage = val + }, + update_currentPage(state, val) { + state.currentPage = val + }, + update_dStartDate(state, val) { + state.dStartDate = val + }, + update_dEndDate(state, val) { + state.dEndDate = val + }, + update_fStartDate(state, val) { + state.fStartDate = val + }, + update_fEndDate(state, val) { + state.fEndDate = val + }, + update_menuStartDate(state, val) { + state.menuStartDate = val + }, + update_menuEndDate(state, val) { + state.menuEndDate = val + }, + update_statusOptions(state, val) { + state.statusOptions = val + }, + update_fStatus(state, val) { + state.fStatus = val + }, + update_fSearch(state, val) { + state.fSearch = val + }, + update_lastId(state, val) { + state.lastId = val + }, + update_loadingStatus(state, val) { + state.loadingStatus = val + }, + update_errorMessage(state, val) { + state.errorMessage = val + }, + update_selectedItems(state, val) { + state.selectedItems = val + }, + update_selectedItem(state, val) { + state.selectedItem = val + }, + update_opendialoginfo(state, val) { + state.opendialoginfo = val + }, + update_msginfo(state, val) { + state.msginfo = val + }, + update_loadingSave(state, val) { + state.loadingSave = val + }, + update_errMessage(state, val) { + state.errMessage = val + }, + update_alertError(state, val) { + state.alertError = val + }, + update_snackbar(state, val) { + state.snackbar = val + }, + update_dialogapprove(state, val) { + state.dialogapprove = val + }, + update_msgapprove(state, val) { + state.msgapprove = val + }, + update_dialogreject(state, val) { + state.dialogreject = val + }, + update_msgreject(state, val) { + state.msgreject = val + }, + updateApproveDivisionUserID(state, val) { + state.approveDivisionUserID = val; + }, + updateApproveDivision(state, val) { + state.approveDivision = val; + } + }, + actions: { + async listrequestitem(context) { + context.commit("update_loadingStatus", 1); + + try { + var prm = { + token: one_token(), + current_page: context.state.currentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus.value, + search: context.state.fSearch + }; + + let response = await api.listrequestitem(prm); + if (response.status != "OK") { + context.commit("update_loadingStatus", 3); + context.commit("update_errorMessage", response.message); + } else { + context.commit("update_loadingStatus", 2); + context.commit("update_errorMessage", ""); + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_request", data.records); + context.commit("update_totalPage", data.total); + + } + } catch (e) { + context.commit("update_loadingStatus", 3); + context.commit("update_errorMessage", e.message); + } + }, + async getDivisionUser(context) { + + try { + var payload = { + token: one_token() + }; + + let response = await api.getDivisionUser(payload); + if (response.status != "OK") { + context.commit("update_errorMessage", response.message); + } else { + context.commit("update_errorMessage", ""); + let data = { + records: response.data.records, + }; + + context.commit("updateApproveDivision", data.records[0].DivisionName); + context.commit("updateApproveDivisionUserID", data.records[0].M_UserDivisionDivisionID); + } + } catch (e) { + context.commit("update_errorMessage", e.message); + } + }, + async approveRequest(context, prm) { + context.commit("update_loadingSave", true); + try { + prm.token = one_token(); + let response = await api.approveRequest(prm); + if (response.status != "OK") { + context.commit("update_loadingSave", false); + context.commit("update_errMessage", response.message); + context.commit("update_alertError", true); + } else { + context.commit("update_loadingSave", false); + + context.commit("update_snackbar", { + state: true, + type: 'success', + message: 'Request berhasil diapprove', + }) + + context.commit("update_dialogapprove", false); + context.commit("update_selectedItems", []); + context.commit("update_selectedItem", {}); + context.dispatch("listrequestitem"); + } + + } catch (e) { + context.commit("update_loadingSave", false); + context.commit("update_errMessage", e.message); + context.commit("update_alertError", true); + } + }, + async rejectedRequest(context, prm) { + context.commit("update_loadingSave", true); + try { + prm.token = one_token(); + let response = await api.rejectedRequest(prm); + if (response.status != "OK") { + context.commit("update_loadingSave", false); + context.commit("update_errMessage", response.message); + context.commit("update_alertError", true); + } else { + context.commit("update_loadingSave", false); + + context.commit("update_snackbar", { + state: true, + type: 'success', + message: 'Request berhasil ditolak', + }) + + context.commit("update_dialogreject", false); + context.commit("update_selectedItems", []); + context.commit("update_selectedItem", {}); + context.dispatch("listrequestitem"); + } + + } catch (e) { + context.commit("update_loadingSave", false); + context.commit("update_errMessage", e.message); + context.commit("update_alertError", true); + } + }, + }, +}; + diff --git a/test/vuex/acc-one-item-out-v3/modules/requester.js b/test/vuex/acc-one-item-out-v3/modules/requester.js new file mode 100644 index 0000000..59dc353 --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/modules/requester.js @@ -0,0 +1,1106 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api-requester.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + mainTable: [], + detailTable: [], + countMainTable: 0, + countDetailTable: 0, + mainTableLoadingStatus: 0, + detailTableLoadingStatus: 0, + mainTableErrorMessage: "", + detailTableErrorMessage: "", + mainTableCurrentPage: 1, + mainTableLastId: -1, + + selectedMainTable: {}, + selectedDetailTable: {}, + + statusOptions: [ + { value: 0, title: "All" }, + { value: 1, title: "Draft" }, + { value: 2, title: "Process" }, + { value: 3, title: "Rejected" } + ], + regionalOptions: [], + branchOptions: [], + + menuStartDate: false, + menuEndDate: false, + menuDateUse: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + fStatus: {value: 0, title: "All"}, + fSearch: "", + + dDateUse: new Date().toISOString().substr(0, 10), + xDateUse: moment(new Date()).format("YYYY-MM-DD"), + warehouseOptions: [], + xWarehouse: "", + xNote: "", + departmentOptions: [], + xDepartment: "", + xDescription: "", + xTotalPrice: "", + xIOID: 0, + xNumber: "", + xIODID: 0, + xDescriptionDetail: "", + xAmountRequest: 0, + xEstimationPrice: 0, + + dialogRequest: false, + dialogDetail: false, + act: "new", + errMessage: "", + successMessage: "", + alertError: false, + alertSuccess: false, + errors: [], + loadingAutocomplete: false, + dialogFormItem: false, + itemList: [], + selectedItem: {}, + search_item: "", + xQty: "", + xPrice: "", + xIsCito: false, + itemsTemp: [], + erroritems: [], + dialogErrors: false, + item_units: [], + selected_item_unit: {}, + search_item_unit: "", + total_price: 0, + errorsform: [], + divisionOptions: [], + selectedDivision: {}, + dialogItem: false, + searchItem: "", + loadingItem: false, + itemCurrentPage: 1, + items: [], + selectedItems: [], + itemTotalPage: 0, + loadingSave: false, + emptycheck: [], + emptycheckvalue: [], + + dialogApprove: false, + detailItemouts: [], + dialogPreview: false, + dialog_batchitem: false, + list_batchitemform: {}, + form_batchitem: [], + buffer_detailitem: {}, + approveLevelID: 0, + dialogProcess: false, + tempBatchNumber: { + records: [], + total: 0 + }, + dialogConfirm: false + }, + mutations: { + updateErrorsform(state, val) { + state.errorsform = val + }, + updateUser(state, val) { + state.user = val + }, + updateMainTable(state, val) { + state.mainTable = val; + }, + updateDetailTable(state, val) { + state.detailTable = val; + }, + updateCountMainTable(state, val) { + state.countMainTable = val; + }, + updateCountDetailTable(state, val) { + state.countDetailTable = val; + }, + updateMainTableLoadingStatus(state, val) { + state.mainTableLoadingStatus = val; + }, + updateDetailTableLoadingStatus(state, val) { + state.detailTableLoadingStatus = val; + }, + updateMainTableErrorMessage(state, val) { + state.mainTableErrorMessage = val; + }, + updateDetailTableErrorMessage(state, val) { + state.detailTableErrorMessage = val; + }, + updateMainTableCurrentPage(state, val) { + state.mainTableCurrentPage = val; + }, + updateMainTableLastId(state, val) { + state.mainTableLastId = val; + }, + + updateSelectedMainTable(state, val) { + state.selectedMainTable = val; + }, + updateSelectedDetailTable(state, val) { + state.selectedDetailTable = val; + }, + + updateRegionalOptions(state, val) { + state.regionalOptions = val; + }, + + updateBranchOptions(state, val) { + state.branchOptions = val; + }, + + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + updateMenuDateUse(state, val) { + state.menuDateUse = val; + }, + + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateFStatus(state, val) { + state.fStatus = val; + }, + updateFSearch(state, val) { + state.fSearch = val; + }, + + updateDDateUse(state, val) { + state.dDateUse = val; + }, + updateXDateUse(state, val) { + state.xDateUse = val; + }, + updateWarehouseOptions(state, val) { + state.warehouseOptions = val + }, + updateXWarehouse(state, val) { + state.xWarehouse = val; + }, + updateXNote(state, val) { + state.xNote = val + }, + updateDepartmentOptions(state, val) { + state.departmentOptions = val + }, + updateXDepartment(state, val) { + state.xDepartment = val + }, + updateXDescription(state, val) { + state.xDescription = val; + }, + updateXTotalPrice(state, val) { + state.xTotalPrice = val; + }, + updateXIOID(state, val) { + state.xIOID = val; + }, + updateXNumber(state, val) { + state.xNumber = val; + }, + updateXIODID(state, val) { + state.xIODID = val; + }, + updateXDescriptionDetail(state, val) { + state.xDescriptionDetail = val; + }, + updateXAmountRequest(state, val) { + state.xAmountRequest = val; + }, + updateXEstimationPrice(state, val) { + state.xEstimationPrice = val; + }, + + updateDialogRequest(state, val) { + state.dialogRequest = val; + }, + updateDialogDetail(state, val) { + state.dialogDetail = val; + }, + updateAct(state, val) { + state.act = val; + }, + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateSuccessMessage(state, val) { + state.successMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateAlertSuccess(state, val) { + state.alertSuccess = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + updateLoadingAutocomplete(state, val) { + state.loadingAutocomplete = val + }, + updateDialogFormItem(state, val) { + state.dialogFormItem = val + }, + updateItemList(state, val) { + state.itemList = val + }, + updateSelectedItem(state, val) { + state.selectedItem = val + }, + update_search_item(state, val) { + state.search_item = val + }, + updateXQty(state, val) { + state.xQty = val + }, + updateXPrice(state, val) { + state.xPrice = val + }, + updateXIsCito(state, val) { + state.xIsCito = val + }, + updateItemsTemp(state, val) { + state.itemsTemp = val + }, + updateErroritems(state, val) { + state.erroritems = val + }, + updateDialogErrors(state, val) { + state.dialogErrors = val + }, + updateItemUnits(state, val) { + state.item_units = val + }, + updateSelectedItemUnit(state, val) { + state.selected_item_unit = val + }, + updateSearchItemUnit(state, val) { + state.search_item_unit = val + }, + updateTotalPrice(state, val) { + state.total_price = val + }, + updateDivisionOptions(state, val) { + state.divisionOptions = val + }, + updateSelectedDivision(state, val) { + state.selectedDivision = val + }, + updateDialogItem(state, val) { + state.dialogItem = val + }, + updateSearchItem(state, val) { + state.searchItem = val + }, + updateLoadingItem(state, val) { + state.loadingItem = val + }, + updateItemCurrentPage(state, val) { + state.itemCurrentPage = val + }, + updateItems(state, val) { + state.items = val + }, + updateSelectedItems(state, val) { + state.selectedItems = val + }, + updateItemTotalPage(state, val) { + state.itemTotalPage = val + }, + updateLoadingSave(state, val) { + state.loadingSave = val + }, + updateEmptycheck(state, val) { + state.emptycheck = val + }, + updateEmptycheckvalue(state, val) { + state.emptycheckvalue = val + }, + updateDialogApprove(state, val) { + state.dialogApprove = val + }, + updateDetailItemouts(state, val) { + state.detailItemouts = val + }, + updateDialogPreview(state, val) { + state.dialogPreview = val + }, + update_dialog_batchitem(state, val) { + state.dialog_batchitem = val + }, + update_list_batchitemform(state, data) { + state.list_batchitemform = data + }, + update_form_batchitem(state, data) { + state.form_batchitem = data + }, + update_buffer_detailitem(state, data) { + state.buffer_detailitem = data + }, + updateApproveLevelID(state, val) { + state.approveLevelID = val; + }, + updateDialogProcess(state, val) { + state.dialogProcess = val + }, + updateTempBatchNumber(state, val) { + state.tempBatchNumber = val + }, + updateDialogConfirm(state, val) { + state.dialogConfirm = val + } + }, + actions: { + async search(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var prm = { + token: one_token(), + current_page: context.state.mainTableCurrentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus.title, + search: context.state.fSearch, + mainTableLastId: -1, + }; + + let response = await api.search(prm); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("updateMainTable", data.records); + context.commit("updateCountMainTable", data.total); + + if (context.state.mainTableLastId == -1) { + if (response.data && response.data.records.length > 0) { + context.commit("updateSelectedMainTable", response.data.records[0]) + } + } else { + let idx = _.findIndex(resp.data.records, function (o) { + return o.T_ItemOutID == context.state.updateSelectedMainTable.T_ItemOutID + }); + if (idx >= 0) { + context.commit("updateSelectedMainTable", resp.data.records[idx]); + } + } + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async searchDetail(context) { + context.commit("updateDetailTableLoadingStatus", 1); + + try { + var prm = { + token: one_token(), + IOID: context.state.selectedMainTable.T_ItemOutID, + }; + + let response = await api.searchDetail(prm); + if (response.status != "OK") { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", response.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("updateDetailTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateDetailTable", data.records); + context.commit("updateCountDetailTable", data.total); + } + } catch (e) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", e.message); + } + }, + + async saveRequest(context, prm) { + context.commit("updateLoadingSave", true); + try { + prm.token = one_token(); + + let response = await api.saveRequest(prm); + if (response.status !== "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateSelectedItems", []); + context.commit("updateSelectedItem", {}); + context.commit("updateItems", []); + context.commit("updateItemTotalPage", 0); + context.commit("updateItemCurrentPage", 1); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = "Berhasil simpan pengeluaran barang"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateRequest(context, prm) { + try { + prm.token = one_token(); + + let response = await api.updateRequest(prm); + if (response.status !== "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = "Berhasil update pengeluaran barang"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteRequest(context, prm) { + try { + prm.token = one_token(); + + let response = await api.deleteRequest(prm); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = `Pengeluaran barang dengan kode ${prm.Number} berhasil dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async saveDetail(context, prm) { + try { + prm.token = one_token(); + + let response = await api.saveDetail(prm); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = "Request baru " + prm.itemDescription + " sudah tersimpan"; + context.commit("updateSuccessMessage", msg); + // context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors[0].msg); + context.commit("updateDialogErrors", true); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateDetail(context, prm) { + try { + prm.token = one_token(); + + let response = await api.updateDetail(prm); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = "Perubahan Request item " + prm.itemDescription + " berhasil disimpan"; + context.commit("updateSuccessMessage", msg); + // context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteDetail(context, prm) { + try { + prm.token = one_token(); + + let response = await api.deleteDetail(prm); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request [${prm.itemDescription}] sudah dihapus`; + context.commit("updateSuccessMessage", msg); + // context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getWarehouse(context) { + context.commit("updateLoadingAutocomplete", true) + try { + let prm = {} + prm.regionalID = context.state.user.S_RegionalID + prm.branchCode = context.state.user.M_BranchCode + prm.token = one_token() + let response = await api.getWarehouse(prm); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + context.commit("updateLoadingAutocomplete", false) + } else { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + }; + + context.commit("updateWarehouseOptions", data.records); + context.commit("updateXWarehouse", data.records[0]); + } + } catch (e) { + context.commit("updateLoadingAutocomplete", true) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getDepartment(context) { + context.commit("updateLoadingAutocomplete", true) + try { + let prm = {} + prm.token = one_token() + let response = await api.getDepartment(prm); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + context.commit("updateLoadingAutocomplete", false) + } else { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + }; + + context.commit("updateDepartmentOptions", data.records); + } + } catch (e) { + context.commit("updateLoadingAutocomplete", true) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async searchItem(context, prm) { + context.commit("updateLoadingAutocomplete", true) + try { + prm.token = one_token() + let resp = await api.searchItem(prm) + if (resp.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", resp.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", ""); + let data = { + records: resp.data.records + } + + context.commit("updateItemList", data.records) + } + } catch (e) { + context.commit("updateLoadingAutocomplete", true) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getUnit(context, prm) { + context.commit("updateLoadingAutocomplete", true) + try { + prm.token = one_token() + let resp = await api.getUnit(prm) + if (resp.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", resp.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", ""); + let data = { + records: resp.data.records + } + + context.commit("updateItemUnits", data.records) + } + } catch (e) { + context.commit("updateLoadingAutocomplete", true) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async orderConfirm(context, prm) { + try { + prm.token = one_token(); + + let response = await api.orderConfirm(prm); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getDivisionByUser(context, prm) { + context.commit("updateLoadingAutocomplete", true) + try { + prm.token = one_token() + prm.userId = context.state.user.M_UserID + let response = await api.getDivisionByUser(prm); + if (response.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + let data = { + records: response.data.records, + selected: response.data.selected + }; + context.commit("updateErrMessage", ""); + context.commit("updateDivisionOptions", data.records); + context.commit("updateSelectedDivision", data.selected[0]); + } + } catch (e) { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getItemRequest(context, prm) { + context.commit("updateLoadingItem", true) + try { + prm.token = one_token() + prm.currentPage = context.state.itemCurrentPage; + let response = await api.getItemRequest(prm); + if (response.status != "OK") { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", ""); + context.commit("updateItems", response.data.records); + context.commit("updateItemTotalPage", response.data.total); + } + } catch (e) { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getDetailItemOut(context, prm) { + context.commit("updateLoadingItem", true) + try { + prm.token = one_token() + let response = await api.getDetailItemOut(prm); + if (response.status != "OK") { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", ""); + context.commit("updateSelectedItems", response.data.records); + } + } catch (e) { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getItemOuts(context, prm) { + context.commit("updateLoadingItem", true) + try { + prm.token = one_token() + let response = await api.getItemOuts(prm); + if (response.status != "OK") { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", ""); + context.commit("updateDetailItemouts", response.data.records); + } + } catch (e) { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async confirmIO(context, prm) { + context.commit("updateLoadingSave", true); + try { + prm.token = one_token(); + + let response = await api.confirmIO(prm); + if (response.status !== "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogConfirm", false); + var msg = "Berhasil konfirmasi pengeluaran barang"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async approveIO(context, prm) { + context.commit("updateLoadingSave", true); + try { + prm.token = one_token(); + + let response = await api.approveIO(prm); + if (response.status !== "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogApprove", false); + var msg = "Berhasil APPROVE pengeluaran barang"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async processIO(context, prm) { + context.commit("updateLoadingSave", true); + try { + prm.token = one_token(); + + let response = await api.processIO(prm); + if (response.status !== "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogProcess", false); + var msg = "Berhasil Proses pengeluaran barang"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async rejectRequest(context, prm) { + context.commit("updateLoadingSave", true); + try { + prm.token = one_token(); + + let response = await api.rejectRequest(prm); + if (response.status !== "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", ""); + let data = { + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogApprove", false); + var msg = "Berhasil REJECT pengeluaran barang"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getBatchItemDetail(context, params) { + try { + params.token = one_token() + params.regionalid = context.state.user.S_RegionalID + params.branchid = context.state.user.M_BranchID + + let resp = await api.getItemBatchListing(params) + if (resp.status != 'OK') { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + context.commit("update_list_batchitemform", resp.data) + + let newBatchNumber = resp.data.records; + let updateBatchNumber = context.state.tempBatchNumber.records + // console.log('before updateBatchNumber module', updateBatchNumber) + // console.log('before recordIndex module', newBatchNumber) + updateBatchNumber.forEach(bn => { + let recordIndex = newBatchNumber.findIndex(record => + record.StockBatchNo === bn.StockBatchNo && + record.StockItemID === bn.StockItemID && + record.StockItemUnitID === bn.StockItemUnitID + + ); + + // console.log('newBatchNumber module', newBatchNumber) + // console.log('recordIndex module', recordIndex) + + if (recordIndex !== -1) { + let updatestock = updateBatchNumber[recordIndex].StockQty + newBatchNumber[recordIndex].StockQty = String(updatestock) + + // Atau hapus record jika StockQty menjadi 0 + // if (stok <= 0) { + // newBatchNumber.splice(recordIndex, 1); + // } + + } + }); + + let newBatch = { + records: newBatchNumber, + total: newBatchNumber.length + }; + context.commit("update_list_batchitemform", newBatch) + } + } catch (error) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getlevel(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var payload = { + token: one_token() + }; + + let resp = await api.getlevel(payload); + if (resp.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", resp.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: resp.data.records, + total: resp.data.total, + }; + + // context.commit("updateLevelName", data.records[0].M_ApproveLevelName); + context.commit("updateApproveLevelID", data.records[0].M_ApproveLevelID); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + } + }, +}; + diff --git a/test/vuex/acc-one-item-out-v3/store.js b/test/vuex/acc-one-item-out-v3/store.js new file mode 100644 index 0000000..feacfcb --- /dev/null +++ b/test/vuex/acc-one-item-out-v3/store.js @@ -0,0 +1,13 @@ +import listrequest from "./modules/listrequest.js"; +import requester from "./modules/requester.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + listrequest: listrequest, + requester: requester, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-item-usage-v3/api/api.js b/test/vuex/acc-one-item-usage-v3/api/api.js new file mode 100644 index 0000000..034aaeb --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/api/api.js @@ -0,0 +1,166 @@ +const URL = "/one-api/mockup/itemout/"; + +export async function getDivisionByUser(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/getDivisionByUser', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function search(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/search', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getUnit(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/getUnit', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function saveItemUsage(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/saveItemUsage', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +// item used +export async function getItemUsed(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/getItemUsed', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function updateItemUsed(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/updateItemUsed', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function deleteItemUsed(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/deleteItemUsed', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function confirmItemUsed(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/confirmItemUsed', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getUnitByItemId(payload) { + try { + var resp = await axios.post(URL + 'itemusagev3/getUnitByItemId', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-item-usage-v3/components/dialogDetailUsageItem.vue b/test/vuex/acc-one-item-usage-v3/components/dialogDetailUsageItem.vue new file mode 100644 index 0000000..7b80fc6 --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/components/dialogDetailUsageItem.vue @@ -0,0 +1,310 @@ + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-usage-v3/components/dialogUsageItem.vue b/test/vuex/acc-one-item-usage-v3/components/dialogUsageItem.vue new file mode 100644 index 0000000..019f17e --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/components/dialogUsageItem.vue @@ -0,0 +1,168 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-usage-v3/components/itemUsageList.vue b/test/vuex/acc-one-item-usage-v3/components/itemUsageList.vue new file mode 100644 index 0000000..96a645a --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/components/itemUsageList.vue @@ -0,0 +1,331 @@ + + + + + diff --git a/test/vuex/acc-one-item-usage-v3/components/itemUsedList.vue b/test/vuex/acc-one-item-usage-v3/components/itemUsedList.vue new file mode 100644 index 0000000..d2f84ac --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/components/itemUsedList.vue @@ -0,0 +1,690 @@ + + + + + diff --git a/test/vuex/acc-one-item-usage-v3/index.php b/test/vuex/acc-one-item-usage-v3/index.php new file mode 100644 index 0000000..a777a34 --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/index.php @@ -0,0 +1,119 @@ + + + + + + + + + + + One + + + + + + + + + Error + + + + {{errMessage}} + + + + + + + + Tutup + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-item-usage-v3/modules/usage.js b/test/vuex/acc-one-item-usage-v3/modules/usage.js new file mode 100644 index 0000000..db0534a --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/modules/usage.js @@ -0,0 +1,290 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + errMessage: "", + alertError: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + loadingAutocomplete: false, + divisionOptions: [], + selectedDivision: {}, + user: one_user(), + currentPage: 1, + loadingStatus: 1, // 1 => LOADING, 2 => DONE, 3 => ERROR + itemUsageList: [], + selectedItemUsage: {}, + totalPage: 0, + dialogUsage: false, + unitList: [], + selectedItemUnit: {}, + usedQty: 0, + errors: [], + last_id: -1, + xsearch: "", + dialogform: false, + itemRequestList: [], + emptycheck: [], + dialogUnit: false, + selectedUnit: {}, + unitOptions: [], + loadingUnit: false, + }, + mutations: { + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateSnackbar(state, val) { + state.snackbar = val; + }, + updateLoadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + updateDivisionOptions(state, val) { + state.divisionOptions = val; + }, + updateSelectedDivision(state, val) { + state.selectedDivision = val; + }, + updateUser(state, val) { + state.user = val; + }, + updateCurrentPage(state, val) { + state.currentPage = val; + }, + updateLoadingStatus(state, val) { + state.loadingStatus = val; + }, + updateItemUsageList(state, val) { + state.itemUsageList = val; + }, + updateSelectedItemUsage(state, val) { + state.selectedItemUsage = val; + }, + updateTotalPage(state, val) { + state.totalPage = val; + }, + updateDialogUsage(state, val) { + state.dialogUsage = val; + }, + updateUnitList(state, val) { + state.unitList = val; + }, + updateSelectedItemUnit(state, val) { + state.selectedItemUnit = val; + }, + updateUsedQty(state, val) { + state.usedQty = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + update_last_id(state, val) { + state.last_id = val + }, + updateXsearch(state, val) { + state.xsearch = val + }, + updateDialogform(state, val) { + state.dialogform = val + }, + updateItemRequestList(state, val) { + state.itemRequestList = val + }, + updateEmptycheck(state, val) { + state.emptycheck = val + }, + updateLoadingUnit(state, val) { + state.loadingUnit = val; + }, + updateDialogUnit(state, val) { + state.dialogUnit = val; + }, + updateSelectedUnit(state, val) { + state.selectedUnit = val; + }, + updateUnitOptions(state, val) { + state.unitOptions = val; + } + }, + actions: { + async getDivisionByUser(context) { + context.commit("updateLoadingAutocomplete", true) + try { + let payload = {} + payload.token = one_token() + payload.userId = context.state.user.M_UserID + let response = await api.getDivisionByUser(payload); + if (response.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + let data = { + records: response.data.records, + selected: response.data.selected + }; + context.commit("updateDivisionOptions", data.records); + context.commit("updateSelectedDivision", data.selected[0]); + } + } catch (e) { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async search(context, payload) { + context.commit("updateLoadingStatus", 1); + try { + // var payload = { + // token: one_token(), + // currentPage: context.state.currentPage, + // divisionID: context.state.selectedDivision == undefined ? 0 : context.state.selectedDivision.DivisionID, + // search: context.state.xsearch, + // }; + payload.token = one_token(); + + let response = await api.search(payload); + if (response.status != "OK") { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingStatus", 2); + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total_page: response.data.total_page, + }; + + context.commit("updateItemUsageList", data.records); + context.commit("updateTotalPage", data.total_page); + + if (context.state.last_id == -1) { + if (response.data && response.data.records.length > 0) { + context.commit("updateSelectedItemUsage", response.data.records[0]) + } + } else { + let idx = _.findIndex(response.data.records, function (o) { + return o.ItemUsageID == context.state.selectedItemUsage.ItemUsageID + }); + if (idx >= 0) { + context.commit("updateSelectedItemUsage", response.data.records[idx]); + } + } + } + } catch (e) { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getUnit(context, payload) { + context.commit("updateLoadingAutocomplete", 1); + try { + payload.token = one_token() + + let response = await api.getUnit(payload); + if (response.status != "OK") { + context.commit("updateLoadingAutocomplete", 3); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", 2); + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records + }; + + context.commit("updateUnitList", data.records); + } + } catch (e) { + context.commit("updateLoadingAutocomplete", 3); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async saveItemUsage(context, payload) { + context.commit("updateLoadingStatus", 1); + try { + payload.token = one_token(); + + let response = await api.saveItemUsage(payload); + if (response.status != "OK") { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingStatus", 2); + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + }; + + + context.commit("updateDialogform", false); + context.commit("updateItemRequestList", []); + context.commit("update_last_id", payload.ItemUsageID) + + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Item usage saved successfully.' + }); + context.dispatch("search", { + currentPage: payload.currentPageUsage, + divisionID: payload.divisionID, + search: payload.searchUsage + }); + context.dispatch("used/getItemUsed", { + itemUsageID: payload.ItemUsageID, + currentPage: payload.currentPage, + search: payload.search, + statusConfirm: payload.statusConfirm, + }, { root: true }); + } + } catch (e) { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getUnitByItemId(context, payload) { + context.commit("updateLoadingUnit", true) + context.commit("updateDialogUnit", true); + try { + payload.token = one_token(); + let response = await api.getUnitByItemId(payload); + if (response.status != "OK") { + context.commit("updateLoadingUnit", false) + context.commit("updateDialogUnit", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingUnit", false) + context.commit("updateErrMessage", ""); + context.commit("updateUnitOptions", response.data.records); + context.commit("updateSelectedUnit", payload.selectedUnit); + + } + } catch (e) { + context.commit("updateLoadingUnit", false) + context.commit("updateDialogUnit", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + } + } +}; \ No newline at end of file diff --git a/test/vuex/acc-one-item-usage-v3/modules/used.js b/test/vuex/acc-one-item-usage-v3/modules/used.js new file mode 100644 index 0000000..0db9034 --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/modules/used.js @@ -0,0 +1,280 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + errMessage: "", + alertError: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + user: one_user(), + currentPage: 1, + loadingStatus: 1, // 1 => LOADING, 2 => DONE, 3 => ERROR + itemUsedList: [], + selectedItemUsed: {}, + totalPageUsed: 0, + selectedUsedQty: 0, + dialogUsed: false, + errors: [], + dialogDelete: false, + dialogConfirmation: false, + search: "", + statusConfirmOptions: [ + { value: "X", text: "Semua" }, + { value: "N", text: "Belum Dikonfirmasi" }, + { value: "Y", text: "Sudah Dikonfirmasi" }, + + ], + statusConfirm: "X", + menuStartDate: false, + menuEndDate: false, + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10) + }, + mutations: { + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateSnackbar(state, val) { + state.snackbar = val; + }, + updateLoadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + updateDivisionOptions(state, val) { + state.divisionOptions = val; + }, + updateSelectedDivision(state, val) { + state.selectedDivision = val; + }, + updateUser(state, val) { + state.user = val; + }, + updateCurrentPage(state, val) { + state.currentPage = val; + }, + updateLoadingStatus(state, val) { + state.loadingStatus = val; + }, + updateItemUsedList(state, val) { + state.itemUsedList = val; + }, + updateSelectedItemUsed(state, val) { + state.selectedItemUsed = val; + }, + updateTotalPageUsed(state, val) { + state.totalPageUsed = val; + }, + updateSelectedUsedQty(state, val) { + state.selectedUsedQty = val; + }, + updateDialogUsed(state, val) { + state.dialogUsed = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + updateDialogDelete(state, val) { + state.dialogDelete = val; + }, + updateDialogConfirmation(state, val) { + state.dialogConfirmation = val; + }, + updateSearch(state, val) { + state.search = val; + state.currentPage = 1; // Reset to first page on new search + }, + updateStatusConfirm(state, val) { + state.statusConfirm = val; + }, + updateStatusConfirmOptions(state, val) { + state.statusConfirmOptions = val; + }, + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + } + }, + actions: { + async getItemUsed(context, payload) { + context.commit("updateLoadingStatus", 1); + try { + payload.token = one_token(); + // var payload = { + // itemUsageID: context.state.usage.selectedItemUsage.ItemUsageID, + // currentPage: context.state.currentPage, + // search: context.state.search, + // statusConfirm: context.state.statusConfirm, + // token: one_token() + // }; + + let response = await api.getItemUsed(payload); + if (response.status != "OK") { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingStatus", 2); + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total_page: response.data.total_page, + }; + + context.commit("updateItemUsedList", data.records); + context.commit("updateTotalPageUsed", data.total_page); + } + } catch (e) { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateItemUsed(context, payload) { + context.commit("updateLoadingStatus", 1); + try { + payload.token = one_token(); + + let response = await api.updateItemUsed(payload); + if (response.status != "OK") { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingStatus", 2); + context.commit("updateErrMessage", ""); + + + context.commit("updateDialogUsed", false); + context.commit("updateSelectedItemUsed", {}); + context.commit("updateSelectedUsedQty", 0); + context.commit("usage/update_last_id", payload.itemUsageID, { root: true }); + + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Item used berhasil diupdate.' + }); + context.dispatch("usage/search",{}, { root: true }); + context.dispatch("getItemUsed", { + itemUsageID: payload.itemUsageID, + currentPage: payload.currentPage, + search: payload.search, + statusConfirm: payload.statusConfirm, + startdate: payload.startdate, + enddate: payload.enddate + }); + } + } catch (e) { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteItemUsed(context, payload) { + context.commit("updateLoadingStatus", 1); + try { + payload.token = one_token(); + + let response = await api.deleteItemUsed(payload); + if (response.status != "OK") { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingStatus", 2); + context.commit("updateErrMessage", ""); + + + context.commit("updateDialogDelete", false); + context.commit("updateSelectedItemUsed", {}); + context.commit("usage/update_last_id", payload.itemUsageID, { root: true }); + + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Item used berhasil dihapus.' + }); + context.dispatch("usage/search",{}, { root: true }); + context.dispatch("getItemUsed", { + itemUsageID: payload.itemUsageID, + currentPage: payload.currentPage, + search: payload.search, + statusConfirm: payload.statusConfirm, + startdate: payload.startdate, + enddate: payload.enddate + }); + } + } catch (e) { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async confirmItemUsed(context, payload) { + context.commit("updateLoadingStatus", 1); + try { + payload.token = one_token(); + + let response = await api.confirmItemUsed(payload); + if (response.status != "OK") { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingStatus", 2); + context.commit("updateErrMessage", ""); + + + context.commit("updateSelectedItemUsed", {}); + context.commit("updateDialogConfirmation", false); + context.commit("usage/update_last_id", payload.itemUsageID, { root: true }); + + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Item used berhasil dikonfirmasi.' + }); + context.dispatch("getItemUsed", { + itemUsageID: payload.itemUsageID, + currentPage: payload.currentPage, + search: payload.search, + statusConfirm: payload.statusConfirm, + startdate: payload.startdate, + enddate: payload.enddate + }); + } + } catch (e) { + context.commit("updateLoadingStatus", 3); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + } + } +}; \ No newline at end of file diff --git a/test/vuex/acc-one-item-usage-v3/store.js b/test/vuex/acc-one-item-usage-v3/store.js new file mode 100644 index 0000000..75868d5 --- /dev/null +++ b/test/vuex/acc-one-item-usage-v3/store.js @@ -0,0 +1,13 @@ +import usage from "./modules/usage.js"; +import used from "./modules/used.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + usage: usage, + used: used, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-jurnal-fix-asset/api/journal.js b/test/vuex/acc-one-jurnal-fix-asset/api/journal.js new file mode 100644 index 0000000..159a561 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/api/journal.js @@ -0,0 +1,282 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + "Journalfixasset/getPeriode", prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search( + token, + xdate, + periodeid, + current_page, + search, + branchCode, + regionalId +) { + try { + var resp = await axios.post(URL + "Journalfixasset/search", { + token: token, + xdate: xdate, + periodeid: periodeid, + current_page: current_page, + search: search, + branchCode: branchCode, + regionalId: regionalId + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertSales(branchCode, date, jurnalno) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertSales/${branchCode}/${date}?isregen=1&jurnalno=${jurnalno}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "Journalfixasset/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "Journalfixasset/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + "Journalfixasset/getUserApproveLevel", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListingCOA(params) { + try { + var resp = await axios.post(URL + "Journalfixasset/getListingCOA", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function requestEditJurnal(params) { + try { + const resp = await axios.post(URL + "JournalVerifEdit/requestEditJurnal", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + const data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditJurnal(params) { + try { + var resp = await axios.post(URL + "JournalVerifEdit/saveEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function changeJurnalToPosted(params) { + try { + var resp = await axios.post(URL + "Journalfixasset/changeJurnalToPosted", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getTotalJurnalNotPostedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journalfixasset/getTotalJurnalNotPostedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function closeJurnalPerPeriode(params) { + try { + var resp = await axios.post(URL + "Journalfixasset/closeJurnalPerPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataJurnalNotClosedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journalfixasset/getDataJurnalNotClosedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-jurnal-fix-asset/components/dialogCloseJurnal.vue b/test/vuex/acc-one-jurnal-fix-asset/components/dialogCloseJurnal.vue new file mode 100644 index 0000000..417ffbb --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/components/dialogCloseJurnal.vue @@ -0,0 +1,76 @@ + + + diff --git a/test/vuex/acc-one-jurnal-fix-asset/components/dialogEditJurnal.vue b/test/vuex/acc-one-jurnal-fix-asset/components/dialogEditJurnal.vue new file mode 100644 index 0000000..0988f33 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/components/dialogEditJurnal.vue @@ -0,0 +1,219 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-fix-asset/components/dialogPostingJurnal.vue b/test/vuex/acc-one-jurnal-fix-asset/components/dialogPostingJurnal.vue new file mode 100644 index 0000000..d611375 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/components/dialogPostingJurnal.vue @@ -0,0 +1,68 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-fix-asset/components/dialogRequestEditJurnal.vue b/test/vuex/acc-one-jurnal-fix-asset/components/dialogRequestEditJurnal.vue new file mode 100644 index 0000000..92715a8 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/components/dialogRequestEditJurnal.vue @@ -0,0 +1,58 @@ + + + diff --git a/test/vuex/acc-one-jurnal-fix-asset/components/oneMediaJournalList.vue b/test/vuex/acc-one-jurnal-fix-asset/components/oneMediaJournalList.vue new file mode 100644 index 0000000..3e578c7 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/components/oneMediaJournalList.vue @@ -0,0 +1,1225 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal-fix-asset/index.php b/test/vuex/acc-one-jurnal-fix-asset/index.php new file mode 100644 index 0000000..a736dd6 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-fix-asset/modules/journal.js b/test/vuex/acc-one-jurnal-fix-asset/modules/journal.js new file mode 100644 index 0000000..734c4af --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/modules/journal.js @@ -0,0 +1,582 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js"; + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: "new", + save_status: 0, + save_error_message: "", + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format("YYYY-MM-DD"), + end_date: moment(new Date()).format("YYYY-MM-DD"), + journals: [], + selected_journal: {}, + summary: { debit: 0, credit: 0, balance: 0 }, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + autocomplete_status: 0, + search_status: 0, + total_journal: 0, + user: one_user(), + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: [], + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + xsearch: "", + open_dialog_info: false, + msg_info: "", + + // -- + dialog_edit_journal: false, + user_level: {}, + list_coa: [], + journal_edit: [], + dialog_confirm_posting: false, + total_jurnal_not_posted: [], + dialog_request_edit: false, + + // --- + dialog_close_jurnal: false, + jurnal_to_close: [] + }, + mutations: { + update_search_status(state, val) { + state.search_status = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_last_id(state, val) { + state.last_id = val; + }, + update_coas(state, val) { + state.coas = val; + }, + update_total_coas(state, val) { + state.total_coas = val; + }, + update_selected_coa(state, val) { + state.selected_coa = val; + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val; + }, + update_act(state, val) { + state.act = val; + }, + update_save_status(state, val) { + state.save_status = val; + }, + update_save_error_message(state, val) { + state.save_error_message = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_msg_success(state, val) { + state.msg_success = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_dialog_error(state, val) { + state.dialog_error = val; + }, + update_open_print(state, value) { + state.open_print = value; + }, + + // --- + update_xdate(state, val) { + state.xdate = val; + }, + update_end_date(state, val) { + state.end_date = val; + }, + update_journals(state, val) { + state.journals = val; + }, + update_selected_journal(state, val) { + state.selected_journal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val; + }, + update_periodeList(state, val) { + state.periodeList = val; + }, + update_selected_periode(state, val) { + state.selected_periode = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val; + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_total_journal(state, val) { + state.total_journal = val; + }, + update_user(state, val) { + state.user = val; + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val; + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val; + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val; + }, + update_regionals(state, val) { + state.regionals = val; + }, + update_selected_regional(state, val) { + state.selected_regional = val; + }, + update_branchs(state, val) { + state.branchs = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.current_page = 1; + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val; + }, + update_msg_info(state, val) { + state.msg_info = val; + }, + + // -- + update_dialog_edit_journal(state, val) { + state.dialog_edit_journal = val; + }, + update_user_level(state, val) { + state.user_level = val; + }, + update_list_coa(state, val) { + state.list_coa = val; + }, + update_journal_edit(state, val) { + state.journal_edit = val; + }, + update_dialog_confirm_posting(state, val) { + state.dialog_confirm_posting = val; + }, + update_total_jurnal_not_posted(state, val) { + state.total_jurnal_not_posted = val; + }, + update_dialog_request_edit(state, val) { + state.dialog_request_edit = val; + }, + + update_dialog_close_jurnal(state, val) { + state.dialog_close_jurnal = val; + }, + update_jurnal_to_close(state, val) { + state.jurnal_to_close = val; + } + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1); + try { + let prm = {}; + prm.token = one_token(); + let resp = await api.getPeriode(prm); + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_autocomplete_status", 2); + let data = resp.data; + context.commit("update_periodeList", resp.data); + + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find( + (p) => + p.periodeMonth == currentMonth.toString() && + p.periodeYear == currentYear + ); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode); + } + } catch (e) { + context.commit("update_autocomplete_status", 3); + } + }, + async search(context, prm) { + context.commit("update_search_status", 1); + try { + let resp = await api.search( + one_token(), + prm.xdate, + prm.periodeid, + prm.current_page, + prm.search, + prm.branchCode, + prm.regionalId + ); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total + }; + + context.commit("update_journals", data.records); + context.commit("update_total_journal", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async insertSales(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalno = prm.jurnalno; + let resp = await api.insertSales(branchCode, date, jurnalno); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getRegional(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getRegional({ + token: one_token(), + regionalId: context.state.user.S_RegionalID + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_regionals", data.records); + context.commit("update_selected_regional", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async getBranch(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getBranch({ + token: one_token(), + regionalId: context.state.selected_regional.S_RegionalID, + branchCode: context.state.user.M_BranchCode + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_branchs", data.records); + context.commit("update_selected_branch", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async postingJurnal(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.changeJurnalToPosted(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_total_jurnal_not_posted", []); + context.commit("update_dialog_confirm_posting", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getUserApprovalLevel(context) { + try { + let param = { token: one_token() }; + const resp = await api.getUserApproveLevel(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getListingCOA(context) { + try { + let param = { + token: one_token(), + keyword: "" + }; + const resp = await api.getListingCOA(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_list_coa", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async requestEditJurnal(context) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + staffID: context.state.user.M_UserID, + staffName: context.state.user.M_UserUsername + }; + const resp = await api.requestEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + context.commit("update_dialog_request_edit", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async saveEditJurnal(context, newdetail) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + jurnalRequestEditID: context.state.selected_journal.JurnalRequestEditID, + oldjurnaltx: context.state.selected_journal.detailtx, + newjurnaltx: newdetail + }; + const resp = await api.saveEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_dialog_edit_journal", false); + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async totalJurnalNotPostedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getTotalJurnalNotPostedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_total_jurnal_not_posted", resp.data.total_jurnal ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getDataJurnalNotClosedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getDataJurnalNotClosedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_jurnal_to_close", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async closeJurnalPerPeriode(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.closeJurnalPerPeriode(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_jurnal_to_close", []); + context.commit("update_dialog_close_jurnal", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + } + } +}; diff --git a/test/vuex/acc-one-jurnal-fix-asset/store.js b/test/vuex/acc-one-jurnal-fix-asset/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fix-asset/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-fixed-asset-v2/api/journal.js b/test/vuex/acc-one-jurnal-fixed-asset-v2/api/journal.js new file mode 100644 index 0000000..56922cb --- /dev/null +++ b/test/vuex/acc-one-jurnal-fixed-asset-v2/api/journal.js @@ -0,0 +1,101 @@ +const URL = "/one-api/fixedasset/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + 'journalfixedassetv2/getPeriode', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search(token, xdate, periodeid, branchid, regionalid) { + try { + var resp = await axios.post(URL + 'journalfixedassetv2/search', { + token:token, + xdate:xdate, + periodeid:periodeid, + branchid:branchid, + regionalid:regionalid + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getdetail(prm) { + try { + var resp = await axios.post(URL + 'journalfixedassetv2/getdetail', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertSales(branchCode, date, jurnalno) { + try { + var resp = await axios.get(URL + `mediajurnalauto/insertSales/${branchCode}/${date}?isregen=1&jurnalno=${jurnalno}`); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function addConfirm(prm) { + try { + var resp = await axios.post(URL + 'journalfixedassetv2/addConfirm', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-jurnal-fixed-asset-v2/components/oneBranchList.vue b/test/vuex/acc-one-jurnal-fixed-asset-v2/components/oneBranchList.vue new file mode 100644 index 0000000..fe104a6 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fixed-asset-v2/components/oneBranchList.vue @@ -0,0 +1,864 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-fixed-asset-v2/components/oneMediaJournalList.vue b/test/vuex/acc-one-jurnal-fixed-asset-v2/components/oneMediaJournalList.vue new file mode 100644 index 0000000..76ae0b9 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fixed-asset-v2/components/oneMediaJournalList.vue @@ -0,0 +1,956 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-fixed-asset-v2/index.php b/test/vuex/acc-one-jurnal-fixed-asset-v2/index.php new file mode 100644 index 0000000..a256f26 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fixed-asset-v2/index.php @@ -0,0 +1,76 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-fixed-asset-v2/modules/journal.js b/test/vuex/acc-one-jurnal-fixed-asset-v2/modules/journal.js new file mode 100644 index 0000000..5eab049 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fixed-asset-v2/modules/journal.js @@ -0,0 +1,361 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js" + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: 'new', + save_status: 0, + save_error_message: '', + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format('YYYY-MM-DD'), + end_date: moment(new Date()).format('YYYY-MM-DD'), + journals: [ + // { + // "journalID": "1", + // "journalNo": "JM002/08", + // "date": "31-08-2024", + // "name": "budhi/budhi", + // "account": "508501001", + // "title": "MS BESIN, SOLAR, PARKIR, TOL, TRANSPORT", + // "description": "ACCRUED PARKIR AGST 24", + // "debit": "275000", + // "credit": "0", + // "posted": "Y" + // }, + // { + // "journalID": "2", + // "journalNo": "JM002/08", + // "date": "31-08-2024", + // "name": "budhi/budhi", + // "account": "2004009", + // "title": "ACCRUED EXP OTHERS", + // "description": "ACCRUED PARKIR AGST 24", + // "debit": "0", + // "credit": "275000", + // "posted": "Y" + // } + ], + selected_journal: {}, + summary: {"debit": 0, "credit": 0, "balance": 0}, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + dialog_form_confirm: false, + autocomplete_status: 0, + search_status: 0, + search_error_message: "", + total_journal: 0, + user: one_user(), + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: [], + user: one_user(), + ishide: 'Y', + branchlists: [] + }, + mutations: { + update_ishide(state, val) { + state.ishide = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_x_search(state, val) { + state.x_search = val + state.current_page = 1 + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_coas(state, val) { + state.coas = val + }, + update_total_coas(state, val) { + state.total_coas = val + }, + update_selected_coa(state, val) { + state.selected_coa = val + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_errors(state, val) { + state.errors = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_dialog_error(state, val) { + state.dialog_error = val + }, + update_open_print(state, value) { + state.open_print = value + }, + + // --- + update_xdate(state, val) { + state.xdate = val + }, + update_end_date(state, val) { + state.end_date = val + }, + update_journals(state, val) { + state.journals = val + }, + update_branchlists(state, val) { + state.branchlists = val + }, + update_selected_journal(state, val) { + state.selected_journal = val + }, + update_summary(state, val) { + state.summary = val + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val + }, + update_periodeList(state, val) { + state.periodeList = val + }, + update_selected_periode(state, val) { + state.selected_periode = val + }, + update_loading(state, val) { + state.loading = val + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val + }, + update_dialog_form_confirm(state, val) { + state.dialog_form_confirm = val + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_total_journal(state, val) { + state.total_journal = val + }, + update_user(state, val) { + state.user = val + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val + }, + update_user(state, val) { + state.user = val + } + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1) + try { + let prm = {} + prm.token = one_token() + let resp = await api.getPeriode(prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_autocomplete_status", 2) + let data = resp.data + + context.commit("update_periodeList", data) + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find(p => p.periodeMonth == currentMonth.toString() && p.periodeYear == currentYear); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + } + }, + async search(context, prm) { + context.commit("update_search_status", 1) + try { + // var prm = { + // token: one_token(), + // periodeid: context.state.selected_periode.id + // } + // var prm = {} + // prm.one_token() + let resp = await api.search(one_token(), prm.xdate, prm.periodeid, prm.branchid, prm.regionalid) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_journals", data.records) + context.commit("update_ishide", data.records[0].ishide) + context.commit("update_total_journal", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async getdetail(context, prm) { + context.commit("update_search_status", 1) + try { + // var prm = { + // token: one_token(), + // periodeid: context.state.selected_periode.id + // } + // var prm = {} + prm.token = one_token() + let resp = await api.getdetail(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_branchlists", data.records) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + + async insertSales(context, prm) { + context.commit("update_save_status", 1) + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalno = prm.jurnalno + let resp = await api.insertSales(branchCode, date, jurnalno) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + context.commit("update_alert_success", true) + var msg = resp.data.msg + context.commit("update_msg_success", msg) + context.dispatch("search", { + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }) + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + async addConfirm(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.addConfirm(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + context.commit("update_alert_success", true) + var msg = " Fixed aset periode " + context.state.selected_periode.periode + " berhasil dikonfirmasi" + context.commit("update_msg_success", msg) + context.dispatch("search", { + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }) + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-fixed-asset-v2/store.js b/test/vuex/acc-one-jurnal-fixed-asset-v2/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-jurnal-fixed-asset-v2/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-item-usage/api/journal.js b/test/vuex/acc-one-jurnal-item-usage/api/journal.js new file mode 100644 index 0000000..ecce4b1 --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/api/journal.js @@ -0,0 +1,282 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + "JournalItemUsage/getPeriode", prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search( + token, + xdate, + periodeid, + current_page, + search, + branchCode, + regionalId +) { + try { + var resp = await axios.post(URL + "JournalItemUsage/search", { + token: token, + xdate: xdate, + periodeid: periodeid, + current_page: current_page, + search: search, + branchCode: branchCode, + regionalId: regionalId + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertSales(branchCode, date, jurnalno) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertSales/${branchCode}/${date}?isregen=1&jurnalno=${jurnalno}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "JournalItemUsage/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "JournalItemUsage/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + "JournalItemUsage/getUserApproveLevel", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListingCOA(params) { + try { + var resp = await axios.post(URL + "JournalItemUsage/getListingCOA", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function requestEditJurnal(params) { + try { + const resp = await axios.post(URL + "JournalVerifEdit/requestEditJurnal", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + const data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditJurnal(params) { + try { + var resp = await axios.post(URL + "JournalVerifEdit/saveEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function changeJurnalToPosted(params) { + try { + var resp = await axios.post(URL + "JournalItemUsage/changeJurnalToPosted", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getTotalJurnalNotPostedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "JournalItemUsage/getTotalJurnalNotPostedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function closeJurnalPerPeriode(params) { + try { + var resp = await axios.post(URL + "JournalItemUsage/closeJurnalPerPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataJurnalNotClosedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "JournalItemUsage/getDataJurnalNotClosedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-jurnal-item-usage/components/dialogCloseJurnal.vue b/test/vuex/acc-one-jurnal-item-usage/components/dialogCloseJurnal.vue new file mode 100644 index 0000000..417ffbb --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/components/dialogCloseJurnal.vue @@ -0,0 +1,76 @@ + + + diff --git a/test/vuex/acc-one-jurnal-item-usage/components/dialogEditJurnal.vue b/test/vuex/acc-one-jurnal-item-usage/components/dialogEditJurnal.vue new file mode 100644 index 0000000..206c1d9 --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/components/dialogEditJurnal.vue @@ -0,0 +1,223 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-item-usage/components/dialogPostingJurnal.vue b/test/vuex/acc-one-jurnal-item-usage/components/dialogPostingJurnal.vue new file mode 100644 index 0000000..dad7a87 --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/components/dialogPostingJurnal.vue @@ -0,0 +1,68 @@ + + + diff --git a/test/vuex/acc-one-jurnal-item-usage/components/dialogRequestEditJurnal.vue b/test/vuex/acc-one-jurnal-item-usage/components/dialogRequestEditJurnal.vue new file mode 100644 index 0000000..92715a8 --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/components/dialogRequestEditJurnal.vue @@ -0,0 +1,58 @@ + + + diff --git a/test/vuex/acc-one-jurnal-item-usage/components/oneMediaJournalList.vue b/test/vuex/acc-one-jurnal-item-usage/components/oneMediaJournalList.vue new file mode 100644 index 0000000..f3c564b --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/components/oneMediaJournalList.vue @@ -0,0 +1,1222 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal-item-usage/index.php b/test/vuex/acc-one-jurnal-item-usage/index.php new file mode 100644 index 0000000..a736dd6 --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-item-usage/modules/journal.js b/test/vuex/acc-one-jurnal-item-usage/modules/journal.js new file mode 100644 index 0000000..11274ff --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/modules/journal.js @@ -0,0 +1,582 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js"; + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: "new", + save_status: 0, + save_error_message: "", + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format("YYYY-MM-DD"), + end_date: moment(new Date()).format("YYYY-MM-DD"), + journals: [], + selected_journal: {}, + summary: { debit: 0, credit: 0, balance: 0 }, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + autocomplete_status: 0, + search_status: 0, + total_journal: 0, + user: one_user(), + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: [], + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + xsearch: "", + open_dialog_info: false, + msg_info: "", + + // -- + dialog_edit_journal: false, + user_level: {}, + list_coa: [], + journal_edit: [], + dialog_confirm_posting: false, + total_jurnal_not_posted: [], + dialog_request_edit: false, + + // --- + dialog_close_jurnal: false, + jurnal_to_close: [] + }, + mutations: { + update_search_status(state, val) { + state.search_status = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_last_id(state, val) { + state.last_id = val; + }, + update_coas(state, val) { + state.coas = val; + }, + update_total_coas(state, val) { + state.total_coas = val; + }, + update_selected_coa(state, val) { + state.selected_coa = val; + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val; + }, + update_act(state, val) { + state.act = val; + }, + update_save_status(state, val) { + state.save_status = val; + }, + update_save_error_message(state, val) { + state.save_error_message = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_msg_success(state, val) { + state.msg_success = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_dialog_error(state, val) { + state.dialog_error = val; + }, + update_open_print(state, value) { + state.open_print = value; + }, + + // --- + update_xdate(state, val) { + state.xdate = val; + }, + update_end_date(state, val) { + state.end_date = val; + }, + update_journals(state, val) { + state.journals = val; + }, + update_selected_journal(state, val) { + state.selected_journal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val; + }, + update_periodeList(state, val) { + state.periodeList = val; + }, + update_selected_periode(state, val) { + state.selected_periode = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val; + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_total_journal(state, val) { + state.total_journal = val; + }, + update_user(state, val) { + state.user = val; + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val; + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val; + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val; + }, + update_regionals(state, val) { + state.regionals = val; + }, + update_selected_regional(state, val) { + state.selected_regional = val; + }, + update_branchs(state, val) { + state.branchs = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.current_page = 1; + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val; + }, + update_msg_info(state, val) { + state.msg_info = val; + }, + + // -- + update_dialog_edit_journal(state, val) { + state.dialog_edit_journal = val; + }, + update_user_level(state, val) { + state.user_level = val; + }, + update_list_coa(state, val) { + state.list_coa = val; + }, + update_journal_edit(state, val) { + state.journal_edit = val; + }, + update_dialog_confirm_posting(state, val) { + state.dialog_confirm_posting = val; + }, + update_total_jurnal_not_posted(state, val) { + state.total_jurnal_not_posted = val; + }, + update_dialog_request_edit(state, val) { + state.dialog_request_edit = val; + }, + + update_dialog_close_jurnal(state, val) { + state.dialog_close_jurnal = val; + }, + update_jurnal_to_close(state, val) { + state.jurnal_to_close = val; + } + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1); + try { + let prm = {}; + prm.token = one_token(); + let resp = await api.getPeriode(prm); + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_autocomplete_status", 2); + let data = resp.data; + context.commit("update_periodeList", resp.data); + + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find( + (p) => + p.periodeMonth == currentMonth.toString() && + p.periodeYear == currentYear + ); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode); + } + } catch (e) { + context.commit("update_autocomplete_status", 3); + } + }, + async search(context, prm) { + context.commit("update_search_status", 1); + try { + let resp = await api.search( + one_token(), + prm.xdate, + prm.periodeid, + prm.current_page, + prm.search, + prm.branchCode, + prm.regionalId + ); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total + }; + + context.commit("update_journals", data.records); + context.commit("update_total_journal", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async insertSales(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalno = prm.jurnalno; + let resp = await api.insertSales(branchCode, date, jurnalno); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getRegional(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getRegional({ + token: one_token(), + regionalId: context.state.user.S_RegionalID + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_regionals", data.records); + context.commit("update_selected_regional", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async getBranch(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getBranch({ + token: one_token(), + regionalId: context.state.selected_regional.S_RegionalID, + branchCode: context.state.user.M_BranchCode + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_branchs", data.records); + context.commit("update_selected_branch", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async postingJurnal(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.changeJurnalToPosted(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_total_jurnal_not_posted", []); + context.commit("update_dialog_confirm_posting", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getUserApprovalLevel(context) { + try { + let param = { token: one_token() }; + const resp = await api.getUserApproveLevel(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getListingCOA(context) { + try { + let param = { + token: one_token(), + keyword: "" + }; + const resp = await api.getListingCOA(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_list_coa", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async requestEditJurnal(context) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + staffID: context.state.user.M_UserID, + staffName: context.state.user.M_UserUsername + }; + const resp = await api.requestEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + context.commit("update_dialog_request_edit", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async saveEditJurnal(context, newdetail) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + jurnalRequestEditID: context.state.selected_journal.JurnalRequestEditID, + oldjurnaltx: context.state.selected_journal.detailtx, + newjurnaltx: newdetail + }; + const resp = await api.saveEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_dialog_edit_journal", false); + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async totalJurnalNotPostedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getTotalJurnalNotPostedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_total_jurnal_not_posted", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getDataJurnalNotClosedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getDataJurnalNotClosedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_jurnal_to_close", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async closeJurnalPerPeriode(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.closeJurnalPerPeriode(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_jurnal_to_close", []); + context.commit("update_dialog_close_jurnal", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + } + } +}; diff --git a/test/vuex/acc-one-jurnal-item-usage/store.js b/test/vuex/acc-one-jurnal-item-usage/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-jurnal-item-usage/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-invoice/api/journal.js b/test/vuex/acc-one-jurnal-payment-invoice/api/journal.js new file mode 100644 index 0000000..8d0f83c --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/api/journal.js @@ -0,0 +1,282 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + "Journalpaymentinv/getPeriode", prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search( + token, + xdate, + periodeid, + current_page, + search, + branchCode, + regionalId +) { + try { + var resp = await axios.post(URL + "Journalpaymentinv/search", { + token: token, + xdate: xdate, + periodeid: periodeid, + current_page: current_page, + search: search, + branchCode: branchCode, + regionalId: regionalId + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertSales(branchCode, date, jurnalno) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertSales/${branchCode}/${date}?isregen=1&jurnalno=${jurnalno}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "Journalpaymentinv/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "Journalpaymentinv/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + "Journalpaymentinv/getUserApproveLevel", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListingCOA(params) { + try { + var resp = await axios.post(URL + "Journalpaymentinv/getListingCOA", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function requestEditJurnal(params) { + try { + const resp = await axios.post(URL + "JournalVerifEdit/requestEditJurnal", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + const data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditJurnal(params) { + try { + var resp = await axios.post(URL + "JournalVerifEdit/saveEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function changeJurnalToPosted(params) { + try { + var resp = await axios.post(URL + "Journalpaymentinv/changeJurnalToPosted", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getTotalJurnalNotPostedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journalpaymentinv/getTotalJurnalNotPostedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function closeJurnalPerPeriode(params) { + try { + var resp = await axios.post(URL + "Journalpaymentinv/closeJurnalPerPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataJurnalNotClosedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journalpaymentinv/getDataJurnalNotClosedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-jurnal-payment-invoice/components/dialogCloseJurnal.vue b/test/vuex/acc-one-jurnal-payment-invoice/components/dialogCloseJurnal.vue new file mode 100644 index 0000000..95a8f00 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/components/dialogCloseJurnal.vue @@ -0,0 +1,76 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-invoice/components/dialogEditJurnal.vue b/test/vuex/acc-one-jurnal-payment-invoice/components/dialogEditJurnal.vue new file mode 100644 index 0000000..d022329 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/components/dialogEditJurnal.vue @@ -0,0 +1,214 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-invoice/components/dialogPostingJurnal.vue b/test/vuex/acc-one-jurnal-payment-invoice/components/dialogPostingJurnal.vue new file mode 100644 index 0000000..dad7a87 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/components/dialogPostingJurnal.vue @@ -0,0 +1,68 @@ + + + diff --git a/test/vuex/acc-one-jurnal-payment-invoice/components/dialogRequestEditJurnal.vue b/test/vuex/acc-one-jurnal-payment-invoice/components/dialogRequestEditJurnal.vue new file mode 100644 index 0000000..80a1939 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/components/dialogRequestEditJurnal.vue @@ -0,0 +1,58 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-invoice/components/oneMediaJournalList.vue b/test/vuex/acc-one-jurnal-payment-invoice/components/oneMediaJournalList.vue new file mode 100644 index 0000000..6d8f83f --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/components/oneMediaJournalList.vue @@ -0,0 +1,1224 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal-payment-invoice/index.php b/test/vuex/acc-one-jurnal-payment-invoice/index.php new file mode 100644 index 0000000..a736dd6 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-invoice/modules/journal.js b/test/vuex/acc-one-jurnal-payment-invoice/modules/journal.js new file mode 100644 index 0000000..88b7a8f --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/modules/journal.js @@ -0,0 +1,583 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js"; + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: "new", + save_status: 0, + save_error_message: "", + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format("YYYY-MM-DD"), + end_date: moment(new Date()).format("YYYY-MM-DD"), + journals: [], + selected_journal: {}, + summary: { debit: 0, credit: 0, balance: 0 }, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + autocomplete_status: 0, + search_status: 0, + total_journal: 0, + user: one_user(), + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: [], + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + xsearch: "", + open_dialog_info: false, + msg_info: "", + + // -- + dialog_edit_journal: false, + user_level: {}, + list_coa: [], + journal_edit: [], + dialog_confirm_posting: false, + total_jurnal_not_posted: [], + dialog_request_edit: false, + + // --- + dialog_close_jurnal: false, + jurnal_to_close: [] + }, + mutations: { + update_search_status(state, val) { + state.search_status = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_last_id(state, val) { + state.last_id = val; + }, + update_coas(state, val) { + state.coas = val; + }, + update_total_coas(state, val) { + state.total_coas = val; + }, + update_selected_coa(state, val) { + state.selected_coa = val; + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val; + }, + update_act(state, val) { + state.act = val; + }, + update_save_status(state, val) { + state.save_status = val; + }, + update_save_error_message(state, val) { + state.save_error_message = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_msg_success(state, val) { + state.msg_success = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_dialog_error(state, val) { + state.dialog_error = val; + }, + update_open_print(state, value) { + state.open_print = value; + }, + + // --- + update_xdate(state, val) { + state.xdate = val; + }, + update_end_date(state, val) { + state.end_date = val; + }, + update_journals(state, val) { + state.journals = val; + }, + update_selected_journal(state, val) { + state.selected_journal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val; + }, + update_periodeList(state, val) { + state.periodeList = val; + }, + update_selected_periode(state, val) { + state.selected_periode = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val; + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_total_journal(state, val) { + state.total_journal = val; + }, + update_user(state, val) { + state.user = val; + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val; + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val; + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val; + }, + update_regionals(state, val) { + state.regionals = val; + }, + update_selected_regional(state, val) { + state.selected_regional = val; + }, + update_branchs(state, val) { + state.branchs = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.current_page = 1; + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val; + }, + update_msg_info(state, val) { + state.msg_info = val; + }, + + // -- + update_dialog_edit_journal(state, val) { + state.dialog_edit_journal = val; + }, + update_user_level(state, val) { + state.user_level = val; + }, + update_list_coa(state, val) { + state.list_coa = val; + }, + update_journal_edit(state, val) { + state.journal_edit = val; + }, + update_dialog_confirm_posting(state, val) { + state.dialog_confirm_posting = val; + }, + update_total_jurnal_not_posted(state, val) { + state.total_jurnal_not_posted = val; + }, + update_dialog_request_edit(state, val) { + state.dialog_request_edit = val; + }, + + update_dialog_close_jurnal(state, val) { + state.dialog_close_jurnal = val; + }, + update_jurnal_to_close(state, val) { + state.jurnal_to_close = val; + } + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1); + try { + let prm = {}; + prm.token = one_token(); + let resp = await api.getPeriode(prm); + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_autocomplete_status", 2); + let data = resp.data; + context.commit("update_periodeList", resp.data); + + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find( + (p) => + p.periodeMonth == currentMonth.toString() && + p.periodeYear == currentYear + ); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode); + } + } catch (e) { + context.commit("update_autocomplete_status", 3); + } + }, + async search(context, prm) { + context.commit("update_search_status", 1); + try { + let resp = await api.search( + one_token(), + prm.xdate, + prm.periodeid, + prm.current_page, + prm.search, + prm.branchCode, + prm.regionalId + ); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total + }; + + context.commit("update_journals", data.records); + context.commit("update_total_journal", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async insertSales(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalno = prm.jurnalno; + let resp = await api.insertSales(branchCode, date, jurnalno); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getRegional(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getRegional({ + token: one_token(), + regionalId: context.state.user.S_RegionalID + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_regionals", data.records); + context.commit("update_selected_regional", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async getBranch(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getBranch({ + token: one_token(), + regionalId: context.state.selected_regional.S_RegionalID, + branchCode: context.state.user.M_BranchCode + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_branchs", data.records); + context.commit("update_selected_branch", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async postingJurnal(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.changeJurnalToPosted(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_total_jurnal_not_posted", []); + context.commit("update_dialog_confirm_posting", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getUserApprovalLevel(context) { + try { + let param = { token: one_token() }; + const resp = await api.getUserApproveLevel(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getListingCOA(context) { + try { + let param = { + token: one_token(), + keyword: "" + }; + const resp = await api.getListingCOA(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_list_coa", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async requestEditJurnal(context) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + staffID: context.state.user.M_UserID, + staffName: context.state.user.M_UserUsername + }; + const resp = await api.requestEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + context.commit("update_dialog_request_edit", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async saveEditJurnal(context, newdetail) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + jurnalRequestEditID: context.state.selected_journal.JurnalRequestEditID, + oldjurnaltx: context.state.selected_journal.detailtx, + newjurnaltx: newdetail + }; + + const resp = await api.saveEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_dialog_edit_journal", false); + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async totalJurnalNotPostedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getTotalJurnalNotPostedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_total_jurnal_not_posted", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getDataJurnalNotClosedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getDataJurnalNotClosedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_jurnal_to_close", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async closeJurnalPerPeriode(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.closeJurnalPerPeriode(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_jurnal_to_close", []); + context.commit("update_dialog_close_jurnal", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + } + } +}; diff --git a/test/vuex/acc-one-jurnal-payment-invoice/store.js b/test/vuex/acc-one-jurnal-payment-invoice/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-invoice/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-voucher/api/journal.js b/test/vuex/acc-one-jurnal-payment-voucher/api/journal.js new file mode 100644 index 0000000..a4db263 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/api/journal.js @@ -0,0 +1,267 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + 'journalpv/getPeriode', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search(token, xdate, periodeid, current_page, search, branchCode, regionalId) { + try { + var resp = await axios.post(URL + 'journalpv/search', { + token:token, + xdate:xdate, + periodeid:periodeid, + current_page:current_page, + search:search, + branchCode:branchCode, + regionalId:regionalId + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertSales(branchCode, date, jurnalno) { + try { + var resp = await axios.get(URL + `mediajurnalauto/insertSales/${branchCode}/${date}?isregen=1&jurnalno=${jurnalno}`); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "journalpv/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "journalpv/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +// edit jurnal section +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + "journalpv/getUserApproveLevel", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getListingCOA(params) { + try { + var resp = await axios.post(URL + "journalpv/getListingCOA", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function requestEditJurnal(params) { + try { + const resp = await axios.post(URL + "JournalVerifEdit/requestEditJurnal", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + const data = resp.data; + return data + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditJurnal(params) { + try { + var resp = await axios.post(URL + "JournalVerifEdit/saveEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function changeJurnalToPosted(params) { + try { + var resp = await axios.post(URL + "journalpv/changeJurnalToPosted", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getTotalJurnalNotPostedPerPeriod(params) { + try { + var resp = await axios.post(URL + "journalpv/getTotalJurnalNotPostedPerPeriod", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function closeJurnalPerPeriode(params) { + try { + var resp = await axios.post(URL + "journalpv/closeJurnalPerPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getDataJurnalNotClosedPerPeriod(params) { + try { + var resp = await axios.post(URL + "journalpv/getDataJurnalNotClosedPerPeriod", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-voucher/components/dialogCloseJurnal.vue b/test/vuex/acc-one-jurnal-payment-voucher/components/dialogCloseJurnal.vue new file mode 100644 index 0000000..95a8f00 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/components/dialogCloseJurnal.vue @@ -0,0 +1,76 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-voucher/components/dialogEditJurnal.vue b/test/vuex/acc-one-jurnal-payment-voucher/components/dialogEditJurnal.vue new file mode 100644 index 0000000..5671519 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/components/dialogEditJurnal.vue @@ -0,0 +1,214 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-voucher/components/dialogPostingJurnal.vue b/test/vuex/acc-one-jurnal-payment-voucher/components/dialogPostingJurnal.vue new file mode 100644 index 0000000..0ae425c --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/components/dialogPostingJurnal.vue @@ -0,0 +1,68 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-voucher/components/dialogRequestEditJurnal.vue b/test/vuex/acc-one-jurnal-payment-voucher/components/dialogRequestEditJurnal.vue new file mode 100644 index 0000000..5352fe5 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/components/dialogRequestEditJurnal.vue @@ -0,0 +1,58 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-voucher/components/oneMediaJournalList.vue b/test/vuex/acc-one-jurnal-payment-voucher/components/oneMediaJournalList.vue new file mode 100644 index 0000000..b92afa8 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/components/oneMediaJournalList.vue @@ -0,0 +1,1226 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal-payment-voucher/index.php b/test/vuex/acc-one-jurnal-payment-voucher/index.php new file mode 100644 index 0000000..a736dd6 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-voucher/modules/journal.js b/test/vuex/acc-one-jurnal-payment-voucher/modules/journal.js new file mode 100644 index 0000000..7bacf97 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/modules/journal.js @@ -0,0 +1,606 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js" + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: 'new', + save_status: 0, + save_error_message: '', + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format('YYYY-MM-DD'), + end_date: moment(new Date()).format('YYYY-MM-DD'), + journals: [ + // { + // "journalID": "1", + // "journalNo": "JM002/08", + // "date": "31-08-2024", + // "name": "budhi/budhi", + // "account": "508501001", + // "title": "MS BESIN, SOLAR, PARKIR, TOL, TRANSPORT", + // "description": "ACCRUED PARKIR AGST 24", + // "debit": "275000", + // "credit": "0", + // "posted": "Y" + // }, + // { + // "journalID": "2", + // "journalNo": "JM002/08", + // "date": "31-08-2024", + // "name": "budhi/budhi", + // "account": "2004009", + // "title": "ACCRUED EXP OTHERS", + // "description": "ACCRUED PARKIR AGST 24", + // "debit": "0", + // "credit": "275000", + // "posted": "Y" + // } + ], + selected_journal: {}, + summary: {"debit": 0, "credit": 0, "balance": 0}, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + autocomplete_status: 0, + search_status: 0, + total_journal: 0, + user: one_user(), + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: [], + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + xsearch: "", + open_dialog_info: false, + msg_info: "", + + // -- + dialog_edit_journal: false, + user_level: {}, + list_coa: [], + journal_edit: [], + dialog_confirm_posting: false, + total_jurnal_not_posted: [], + dialog_request_edit: false, + + // --- + dialog_close_jurnal: false, + jurnal_to_close: [] + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_x_search(state, val) { + state.x_search = val + state.current_page = 1 + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_coas(state, val) { + state.coas = val + }, + update_total_coas(state, val) { + state.total_coas = val + }, + update_selected_coa(state, val) { + state.selected_coa = val + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_errors(state, val) { + state.errors = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_dialog_error(state, val) { + state.dialog_error = val + }, + update_open_print(state, value) { + state.open_print = value + }, + + // --- + update_xdate(state, val) { + state.xdate = val + }, + update_end_date(state, val) { + state.end_date = val + }, + update_journals(state, val) { + state.journals = val + }, + update_selected_journal(state, val) { + state.selected_journal = val + }, + update_summary(state, val) { + state.summary = val + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val + }, + update_periodeList(state, val) { + state.periodeList = val + }, + update_selected_periode(state, val) { + state.selected_periode = val + }, + update_loading(state, val) { + state.loading = val + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_total_journal(state, val) { + state.total_journal = val + }, + update_user(state, val) { + state.user = val + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val + }, + update_regionals(state, val) { + state.regionals = val + }, + update_selected_regional(state, val) { + state.selected_regional = val + }, + update_branchs(state, val) { + state.branchs = val + }, + update_selected_branch(state, val) { + state.selected_branch = val + }, + update_xsearch(state, val) { + state.xsearch = val + state.current_page = 1 + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val + }, + update_msg_info(state, val) { + state.msg_info = val + }, + + update_dialog_edit_journal(state, val) { + state.dialog_edit_journal = val + }, + update_user_level(state, val) { + state.user_level = val + }, + update_list_coa(state, val) { + state.list_coa = val + }, + update_journal_edit(state, val) { + state.journal_edit = val + }, + update_dialog_confirm_posting(state, val) { + state.dialog_confirm_posting = val + }, + update_total_jurnal_not_posted(state, val) { + state.total_jurnal_not_posted = val + }, + update_dialog_request_edit(state, val) { + state.dialog_request_edit = val + }, + + update_dialog_close_jurnal(state, val) { + state.dialog_close_jurnal = val + }, + update_jurnal_to_close(state, val) { + state.jurnal_to_close = val + }, + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1) + try { + let prm = {} + prm.token = one_token() + let resp = await api.getPeriode(prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_autocomplete_status", 2) + let data = resp.data + + context.commit("update_periodeList", data) + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find(p => p.periodeMonth == currentMonth.toString() && p.periodeYear == currentYear); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + } + }, + + async search(context, prm) { + context.commit("update_search_status", 1) + try { + let resp = await api.search( + one_token(), + prm.xdate, + prm.periodeid, + prm.current_page, + prm.search, + prm.branchCode, + prm.regionalId + ) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_journals", data.records) + context.commit("update_total_journal", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + + async insertSales(context, prm) { + context.commit("update_save_status", 1) + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalno = prm.jurnalno + let resp = await api.insertSales(branchCode, date, jurnalno) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + context.commit("update_alert_success", true) + var msg = resp.data.msg + context.commit("update_msg_success", msg) + context.dispatch("search", { + branchCode: prm.branchCode, + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }) + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + + async getRegional(context) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.getRegional({ token: one_token(), regionalId: context.state.user.S_RegionalID }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_regionals", data.records); + context.commit("update_selected_regional", data.selected) + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_autocomplete_status", 3) + } + }, + + async getBranch(context) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.getBranch({ + token: one_token(), + regionalId: context.state.selected_regional.S_RegionalID, + branchCode: context.state.user.M_BranchCode + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_branchs", data.records); + context.commit("update_selected_branch", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_autocomplete_status", 3) + } + }, + + // edit jurnal section + async postingJurnal(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + } + const resp = await api.changeJurnalToPosted(param) + if (resp.status != 'OK') { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_msg_success", resp.data) + context.commit("update_alert_success", true) + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }) + + context.commit("update_total_jurnal_not_posted", []); + context.commit("update_dialog_confirm_posting", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message) + } + }, + + async getUserApprovalLevel(context) { + try { + let param = { token: one_token() } + const resp = await api.getUserApproveLevel(param) + if (resp.status != 'OK') { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message) + } + }, + + async getListingCOA(context) { + try { + let param = { + token: one_token(), + keyword: "" + } + const resp = await api.getListingCOA(param) + if (resp.status != 'OK') { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_list_coa", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message) + } + }, + + async requestEditJurnal(context) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + staffID: context.state.user.M_UserID, + staffName: context.state.user.M_UserUsername + } + const resp = await api.requestEditJurnal(param) + if (resp.status != 'OK') { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_msg_success", resp.data) + context.commit("update_alert_success", true) + context.commit("update_dialog_request_edit", false) + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message) + } + }, + + async saveEditJurnal(context, newdetail) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + jurnalRequestEditID: context.state.selected_journal.JurnalRequestEditID, + oldjurnaltx: context.state.selected_journal.detailtx, + newjurnaltx: newdetail + } + + const resp = await api.saveEditJurnal(param) + if (resp.status != 'OK') { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message) + } else { + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }) + + context.commit("update_dialog_edit_journal", false); + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message) + } + }, + + async totalJurnalNotPostedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + } + const resp = await api.getTotalJurnalNotPostedPerPeriod(param) + if (resp.status != 'OK') { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_total_jurnal_not_posted", resp.data ?? []) + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message) + } + }, + + async getDataJurnalNotClosedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + } + const resp = await api.getDataJurnalNotClosedPerPeriod(param) + if (resp.status != 'OK') { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_jurnal_to_close", resp.data ?? []) + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message) + } + }, + + async closeJurnalPerPeriode(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + } + const resp = await api.closeJurnalPerPeriode(param) + if (resp.status != 'OK') { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_msg_success", resp.data) + context.commit("update_alert_success", true) + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }) + + context.commit("update_jurnal_to_close", []); + context.commit("update_dialog_close_jurnal", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-payment-voucher/store.js b/test/vuex/acc-one-jurnal-payment-voucher/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-jurnal-payment-voucher/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/api/api.js b/test/vuex/acc-one-jurnal-penyesuaian/api/api.js new file mode 100644 index 0000000..0496f9c --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/api/api.js @@ -0,0 +1,196 @@ +const URL = "/one-api/mockup/masterdata/accounting/JournalPenyesuaian/"; + +export async function getDaftarPeriode(params) { + try { + var resp = await axios.post(URL + 'getDaftarPeriode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarTipeJurnal(params) { + try { + var resp = await axios.post(URL + 'getDaftarTipeJurnal', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarJournalClosed(params) { + try { + var resp = await axios.post(URL + 'getDaftarJournalClosed', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDetailJournalClosed(params) { + try { + var resp = await axios.post(URL + 'getDetailJournalClosed', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarAccount(params) { + try { + var resp = await axios.post(URL + 'getDaftarAccount', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveKoreksiJurnal(params) { + try { + var resp = await axios.post(URL + 'saveKoreksiJurnal', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + var data = resp.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getDaftarJournalBalik(params) { + try { + var resp = await axios.post(URL + 'getDaftarJournalBalik', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + var data = resp.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getDetailJournalBalik(params) { + try { + var resp = await axios.post(URL + 'getDetailJournalBalik', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + var data = resp.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function updateStatusKoreksiJurnal(params) { + try { + var resp = await axios.post(URL + 'updateStatusKoreksiJurnal', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + var data = resp.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + 'getUserApproveLevel', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + var data = resp.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/components/dialogAddRowJurnal.vue b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogAddRowJurnal.vue new file mode 100644 index 0000000..14a3fb8 --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogAddRowJurnal.vue @@ -0,0 +1,167 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/components/dialogBalikJurnal.vue b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogBalikJurnal.vue new file mode 100644 index 0000000..d7ae200 --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogBalikJurnal.vue @@ -0,0 +1,365 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/components/dialogSelectJurnal.vue b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogSelectJurnal.vue new file mode 100644 index 0000000..2eb8213 --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogSelectJurnal.vue @@ -0,0 +1,242 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/components/dialogSelectPeriode.vue b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogSelectPeriode.vue new file mode 100644 index 0000000..134be0d --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogSelectPeriode.vue @@ -0,0 +1,91 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/components/dialogViewJurnal.vue b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogViewJurnal.vue new file mode 100644 index 0000000..446e8d8 --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/components/dialogViewJurnal.vue @@ -0,0 +1,193 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/components/one-layout.vue b/test/vuex/acc-one-jurnal-penyesuaian/components/one-layout.vue new file mode 100644 index 0000000..04b4208 --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/components/one-layout.vue @@ -0,0 +1,287 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/index.php b/test/vuex/acc-one-jurnal-penyesuaian/index.php new file mode 100644 index 0000000..581d6f9 --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/index.php @@ -0,0 +1,66 @@ + + + + + + ONE | Jurnal Penyesuaian + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/modules/journal.js b/test/vuex/acc-one-jurnal-penyesuaian/modules/journal.js new file mode 100644 index 0000000..ba6881f --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/modules/journal.js @@ -0,0 +1,477 @@ +import * as api from '../api/api.js'; + +export default { + namespaced: true, + state: { + // dialog + dialog_journal: false, + dialog_journal_balik: false, + dialog_add_jurnaltrx: false, + dialog_view_jurnal: false, + dialog_pick_periode: false, + + // jurnal balik + filter_balik: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + periodeID: 0, + typeJournalID: 0, + search: "" + }, + list_journal_balik: { + records: [], + total: 0 + }, + currpage_balik: 1, + selected_journal_balik: {}, + journal_detail_balik: { + transaction: [], + summary: { + total_debit: 0, + total_kredit: 0, + balance: 0, + } + }, + journal_balik_new: [], + summary_balik_new: { + total_debit: 0, + total_kredit: 0, + balance: 0, + }, + + // list data general + list_periode: [], + selected_periode: {}, + list_typejurnal: [], + list_account: [], + + // jurnal closed + filter_closed: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + periodeID: 0, + typeJournalID: 0, + search: "" + }, + list_journal_closed: { + records: [], + total: 0 + }, + currpage_closed: 1, + selected_journal_closed: { + totals: { + total_debit: 0, + total_kredit: 0, + balance: 0, + } + }, + + // utilities + snackbar: { + color: "primary", + active: false, + message: "" + }, + user_level: {} + }, + mutations: { + // dialog + update_dialog_journal(state, val) { + state.dialog_journal = val + }, + update_dialog_journal_balik(state, val) { + state.dialog_journal_balik = val + }, + update_dialog_add_jurnaltrx(state, val) { + state.dialog_add_jurnaltrx = val + }, + update_dialog_view_jurnal(state, val) { + state.dialog_view_jurnal = val + }, + update_dialog_pick_periode(state, val) { + state.dialog_pick_periode = val + }, + + // jurnal balik + update_filter_balik(state, val) { + state.filter_balik = val + }, + update_list_journal_balik(state, val) { + state.list_journal_balik = val + }, + update_currpage_balik(state, val) { + state.currpage_balik = val + }, + update_selected_journal_balik(state, val) { + state.selected_journal_balik = val + }, + update_journal_detail_balik(state, val) { + state.journal_detail_balik = val + }, + update_journal_balik_new(state, val) { + state.journal_balik_new = val + }, + update_summary_balik_new(state, val) { + state.summary_balik_new = val + }, + + // list data general + update_list_periode(state, val) { + state.list_periode = val + }, + update_selected_periode(state, val) { + state.selected_periode = val + }, + update_list_typejurnal(state, val) { + state.list_typejurnal = val + }, + update_list_account(state, val) { + state.list_account = val + }, + + // journal closed + update_list_journal_closed(state, val) { + state.list_journal_closed = val + }, + update_filter_closed(state, val) { + state.filter_closed = val + }, + update_currpage_closed(state, val) { + state.currpage_closed = val + }, + update_selected_journal_closed(state, val) { + state.selected_journal_closed = val + }, + + // utilities + update_snackbar(state, val) { + state.snackbar = val + }, + update_user_level(state, val) { + state.user_level = val + } + }, + actions: { + async getDaftarPeriode(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + var resp = await api.getDaftarPeriode({ token: one_token() }) + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + context.commit('update_list_periode', resp.data); + + let fbalik = context.state.filter_balik; + let fclosed = context.state.filter_closed; + fbalik.periodeID = resp.data[0].periodeID; + fclosed.periodeID = resp.data[0].periodeID; + + context.commit('update_filter_balik', fbalik); + context.commit('update_filter_closed', fclosed); + context.commit('update_selected_periode', resp.data[0]); + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true } + context.commit('update_snackbar', snac) + } + }, + + async getDaftarTipeJurnal(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + var resp = await api.getDaftarTipeJurnal({ token: one_token() }); + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + context.commit("update_list_typejurnal", resp.data); + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snac); + } + }, + + async getDaftarJournalClosed(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + let params = { + token: one_token(), + currpage: context.state.currpage_closed, + ...context.state.filter_closed + } + + var resp = await api.getDaftarJournalClosed(params) + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + context.commit("update_list_journal_closed", resp.data) + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snac); + } + }, + + async getDetailJournalClosed(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + let params = { + token: one_token(), + jurnalID: context.state.selected_journal_closed.jurnalID + } + + var resp = await api.getDetailJournalClosed(params) + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + let datatx = resp.data + // calculate total debit, kredit, balance + const totals = datatx.reduce((acc, item) => { + const debit = Number(item.jurnalTxDebit) || 0 + const kredit = Number(item.jurnalTxCredit) || 0 + + acc.total_debit += debit + acc.total_kredit += kredit + return acc; + }, {total_debit: 0, total_kredit: 0}) + totals.balance = totals.total_debit - totals.total_kredit + + let selected = context.state.selected_journal_closed + let jrlbalik = context.state.journal_detail_balik + + selected.detail = resp.data + selected.totals = totals + + jrlbalik.transaction = datatx + jrlbalik.summary = totals + + context.commit("update_selected_journal_closed", selected) + context.commit("update_journal_detail_balik", jrlbalik) + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snac); + } + }, + + async getDaftarAccount(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + let param = { + token: one_token(), + keyword: "" + } + var resp = await api.getDaftarAccount(param); + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + context.commit("update_list_account", resp.data) + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snac); + } + }, + + async getDaftarJournalBalik(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + let param = { + token: one_token(), + currpage: context.state.currpage_balik, + ...context.state.filter_balik + } + var resp = await api.getDaftarJournalBalik(param) + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + context.commit("update_list_journal_balik", resp.data) + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snac); + } + }, + + async getDetailJournalBalik(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + let param = { + token: one_token(), + jurnalID: context.state.selected_journal_balik.jurnalID + } + var resp = await api.getDetailJournalBalik(param) + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + let datatx = resp.data + + const summary = datatx.reduce((acc, item) => { + const debit = Number(item.jurnalTxDebit) + const kredit = Number(item.jurnalTxCredit) + + acc.total_debit += debit + acc.total_kredit += kredit + return acc + }, { total_debit: 0, total_kredit: 0 }) + summary.balance = summary.total_debit - summary.total_kredit + + let detail_balik = { + transaction: datatx, + summary: summary + } + context.commit("update_journal_detail_balik", detail_balik) + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snac); + } + }, + + async getUserApproveLevel(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + var resp = await api.getUserApproveLevel({token: one_token()}); + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + context.commit("update_user_level", resp.data) + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snac); + } + }, + + async saveKoreksiJurnal(context) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + let detailtrx = []; + let jurnalbalik = context.state.journal_detail_balik.transaction + jurnalbalik.forEach(item => { + detailtrx.push({ + coaID: item.jurnalTxCoaID, + coaDescription: item.coaDescription, + debit: item.jurnalTxDebit, + kredit: item.jurnalTxCredit, + info: item.jurnalAddOnValue, + infocode: item.jurnalAddOnCode + }) + }); + + let jurnalnew = context.state.journal_balik_new + jurnalnew.forEach(item => { + detailtrx.push({ + coaID: item.jurnalTxCoaID, + coaDescription: item.coaDescription, + debit: item.jurnalTxDebit, + kredit: item.jurnalTxCredit, + info: item.jurnalAddOnValue, + infocode: 'PENYESUAIAN' + }) + }); + + let param = { + token: one_token(), + oldJurnalID: context.state.selected_journal_closed.jurnalID, + jurnalTypeCode: context.state.selected_journal_closed.JurnalTypeCode, + jurnalNo: context.state.selected_journal_closed.jurnalNo, + jurnalDate: context.state.selected_journal_closed.jurnalDate, + detailtrx: detailtrx + } + var resp = await api.saveKoreksiJurnal(param); + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + let snac = { color: 'success', message: resp.data, active: true }; + context.commit('update_snackbar', snac); + + context.state.selected_journal_closed = { + totals: { + total_debit: 0, + total_kredit: 0, + balance: 0, + } + }; + + context.state.journal_detail_balik = { + transaction: [], + summary: { + total_debit: 0, + total_kredit: 0, + balance: 0, + } + }; + + context.state.summary_balik_new = { + total_debit: 0, + total_kredit: 0, + balance: 0, + } + + context.dispatch("getDaftarJournalBalik"); + context.state.dialog_journal_balik = false; + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snac); + } + }, + + async updateStatusJurnalKoreksi(context, status) { + try { + let snac = { color: 'primary', message: '', active: false }; + context.commit('update_snackbar', snac); + + let param = { + token: one_token(), + jurnalID: context.state.selected_journal_balik.jurnalID, + status: status + } + + var resp = await api.updateStatusKoreksiJurnal(param) + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit('update_snackbar', snac); + } else { + let snac = { color: 'success', message: resp.data, active: true }; + context.commit('update_snackbar', snac); + + context.commit("update_selected_journal_balik", {}); + context.dispatch("getDaftarJournalBalik"); + context.commit('update_dialog_view_jurnal', false); + } + } catch (error) { + let snacc = { color: 'error', message: error.message, active: true }; + context.commit('update_snackbar', snacc); + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-penyesuaian/store.js b/test/vuex/acc-one-jurnal-penyesuaian/store.js new file mode 100644 index 0000000..6b8b62f --- /dev/null +++ b/test/vuex/acc-one-jurnal-penyesuaian/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import journal from "./modules/journal.js"; + +export const store = new Vuex.Store({ + modules: { + journal: journal, + system: system + }, + state: {}, + mutations: {}, + actions: {} +}); \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-surat-jalan/api/journal.js b/test/vuex/acc-one-jurnal-surat-jalan/api/journal.js new file mode 100644 index 0000000..c7aa693 --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/api/journal.js @@ -0,0 +1,282 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + "Journalsuratjalan/getPeriode", prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search( + token, + xdate, + periodeid, + current_page, + search, + branchCode, + regionalId +) { + try { + var resp = await axios.post(URL + "Journalsuratjalan/search", { + token: token, + xdate: xdate, + periodeid: periodeid, + current_page: current_page, + search: search, + branchCode: branchCode, + regionalId: regionalId + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertSales(branchCode, date, jurnalno) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertSales/${branchCode}/${date}?isregen=1&jurnalno=${jurnalno}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "Journalsuratjalan/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "Journalsuratjalan/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + "Journalsuratjalan/getUserApproveLevel", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListingCOA(params) { + try { + var resp = await axios.post(URL + "Journalsuratjalan/getListingCOA", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function requestEditJurnal(params) { + try { + const resp = await axios.post(URL + "JournalVerifEdit/requestEditJurnal", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + const data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditJurnal(params) { + try { + var resp = await axios.post(URL + "JournalVerifEdit/saveEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function changeJurnalToPosted(params) { + try { + var resp = await axios.post(URL + "Journalsuratjalan/changeJurnalToPosted", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getTotalJurnalNotPostedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journalsuratjalan/getTotalJurnalNotPostedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function closeJurnalPerPeriode(params) { + try { + var resp = await axios.post(URL + "Journalsuratjalan/closeJurnalPerPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataJurnalNotClosedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journalsuratjalan/getDataJurnalNotClosedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-jurnal-surat-jalan/components/dialogCloseJurnal.vue b/test/vuex/acc-one-jurnal-surat-jalan/components/dialogCloseJurnal.vue new file mode 100644 index 0000000..417ffbb --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/components/dialogCloseJurnal.vue @@ -0,0 +1,76 @@ + + + diff --git a/test/vuex/acc-one-jurnal-surat-jalan/components/dialogEditJurnal.vue b/test/vuex/acc-one-jurnal-surat-jalan/components/dialogEditJurnal.vue new file mode 100644 index 0000000..f7d45aa --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/components/dialogEditJurnal.vue @@ -0,0 +1,223 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-surat-jalan/components/dialogPostingJurnal.vue b/test/vuex/acc-one-jurnal-surat-jalan/components/dialogPostingJurnal.vue new file mode 100644 index 0000000..0ae425c --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/components/dialogPostingJurnal.vue @@ -0,0 +1,68 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-surat-jalan/components/dialogRequestEditJurnal.vue b/test/vuex/acc-one-jurnal-surat-jalan/components/dialogRequestEditJurnal.vue new file mode 100644 index 0000000..92715a8 --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/components/dialogRequestEditJurnal.vue @@ -0,0 +1,58 @@ + + + diff --git a/test/vuex/acc-one-jurnal-surat-jalan/components/oneMediaJournalList.vue b/test/vuex/acc-one-jurnal-surat-jalan/components/oneMediaJournalList.vue new file mode 100644 index 0000000..5244a25 --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/components/oneMediaJournalList.vue @@ -0,0 +1,1224 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal-surat-jalan/index.php b/test/vuex/acc-one-jurnal-surat-jalan/index.php new file mode 100644 index 0000000..a736dd6 --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-surat-jalan/modules/journal.js b/test/vuex/acc-one-jurnal-surat-jalan/modules/journal.js new file mode 100644 index 0000000..b6b04f6 --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/modules/journal.js @@ -0,0 +1,588 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js"; + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: "new", + save_status: 0, + save_error_message: "", + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format("YYYY-MM-DD"), + end_date: moment(new Date()).format("YYYY-MM-DD"), + journals: [], + selected_journal: {}, + summary: { debit: 0, credit: 0, balance: 0 }, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + autocomplete_status: 0, + search_status: 0, + total_journal: 0, + user: one_user(), + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: [], + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + xsearch: "", + open_dialog_info: false, + msg_info: "", + + // -- + dialog_edit_journal: false, + user_level: {}, + list_coa: [], + journal_edit: [], + dialog_confirm_posting: false, + total_jurnal_not_posted: [], + dialog_request_edit: false, + + // --- + dialog_close_jurnal: false, + jurnal_to_close: [] + }, + mutations: { + update_search_status(state, val) { + state.search_status = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_last_id(state, val) { + state.last_id = val; + }, + update_coas(state, val) { + state.coas = val; + }, + update_total_coas(state, val) { + state.total_coas = val; + }, + update_selected_coa(state, val) { + state.selected_coa = val; + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val; + }, + update_act(state, val) { + state.act = val; + }, + update_save_status(state, val) { + state.save_status = val; + }, + update_save_error_message(state, val) { + state.save_error_message = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_msg_success(state, val) { + state.msg_success = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_dialog_error(state, val) { + state.dialog_error = val; + }, + update_open_print(state, value) { + state.open_print = value; + }, + + // --- + update_xdate(state, val) { + state.xdate = val; + }, + update_end_date(state, val) { + state.end_date = val; + }, + update_journals(state, val) { + state.journals = val; + }, + update_selected_journal(state, val) { + state.selected_journal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val; + }, + update_periodeList(state, val) { + state.periodeList = val; + }, + update_selected_periode(state, val) { + state.selected_periode = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val; + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_total_journal(state, val) { + state.total_journal = val; + }, + update_user(state, val) { + state.user = val; + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val; + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val; + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val; + }, + update_user(state, val) { + state.user = val; + }, + update_regionals(state, val) { + state.regionals = val; + }, + update_selected_regional(state, val) { + state.selected_regional = val; + }, + update_branchs(state, val) { + state.branchs = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.current_page = 1; + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val; + }, + update_msg_info(state, val) { + state.msg_info = val; + }, + + // -- + update_dialog_edit_journal(state, val) { + state.dialog_edit_journal = val; + }, + update_user_level(state, val) { + state.user_level = val; + }, + update_list_coa(state, val) { + state.list_coa = val; + }, + update_journal_edit(state, val) { + state.journal_edit = val; + }, + update_dialog_confirm_posting(state, val) { + state.dialog_confirm_posting = val; + }, + update_total_jurnal_not_posted(state, val) { + state.total_jurnal_not_posted = val; + }, + update_dialog_request_edit(state, val) { + state.dialog_request_edit = val; + }, + + update_dialog_close_jurnal(state, val) { + state.dialog_close_jurnal = val; + }, + update_jurnal_to_close(state, val) { + state.jurnal_to_close = val; + } + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1); + try { + let prm = {}; + prm.token = one_token(); + let resp = await api.getPeriode(prm); + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_autocomplete_status", 2); + let data = resp.data; + context.commit("update_periodeList", resp.data); + + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find( + (p) => + p.periodeMonth == currentMonth.toString() && + p.periodeYear == currentYear + ); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode); + } + } catch (e) { + context.commit("update_autocomplete_status", 3); + } + }, + async search(context, prm) { + context.commit("update_search_status", 1); + try { + let resp = await api.search( + one_token(), + prm.xdate, + prm.periodeid, + prm.current_page, + prm.search, + prm.branchCode, + prm.regionalId + ); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total + }; + + context.commit("update_journals", data.records); + context.commit("update_total_journal", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async insertSales(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalno = prm.jurnalno; + let resp = await api.insertSales(branchCode, date, jurnalno); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + branchCode: prm.branchCode, + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getRegional(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getRegional({ + token: one_token(), + regionalId: context.state.user.S_RegionalID + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_regionals", data.records); + context.commit("update_selected_regional", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async getBranch(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getBranch({ + token: one_token(), + regionalId: context.state.selected_regional.S_RegionalID, + branchCode: context.state.user.M_BranchCode + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_branchs", data.records); + context.commit("update_selected_branch", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async postingJurnal(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.changeJurnalToPosted(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_total_jurnal_not_posted", []); + context.commit("update_dialog_confirm_posting", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getUserApprovalLevel(context) { + try { + let param = { token: one_token() }; + const resp = await api.getUserApproveLevel(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getListingCOA(context) { + try { + let param = { + token: one_token(), + keyword: "" + }; + const resp = await api.getListingCOA(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_list_coa", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async requestEditJurnal(context) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + staffID: context.state.user.M_UserID, + staffName: context.state.user.M_UserUsername + }; + const resp = await api.requestEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + context.commit("update_dialog_request_edit", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async saveEditJurnal(context, newdetail) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + jurnalRequestEditID: context.state.selected_journal.JurnalRequestEditID, + oldjurnaltx: context.state.selected_journal.detailtx, + newjurnaltx: newdetail + }; + const resp = await api.saveEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_dialog_edit_journal", false); + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async totalJurnalNotPostedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getTotalJurnalNotPostedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_total_jurnal_not_posted", resp.data.total_jurnal ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getDataJurnalNotClosedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getDataJurnalNotClosedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_jurnal_to_close", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async closeJurnalPerPeriode(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.closeJurnalPerPeriode(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_jurnal_to_close", []); + context.commit("update_dialog_close_jurnal", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + } + } +}; diff --git a/test/vuex/acc-one-jurnal-surat-jalan/store.js b/test/vuex/acc-one-jurnal-surat-jalan/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-jurnal-surat-jalan/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/api/journal.js b/test/vuex/acc-one-jurnal-tukar-faktur/api/journal.js new file mode 100644 index 0000000..48be3f2 --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/api/journal.js @@ -0,0 +1,282 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + "Journaltukarfaktur/getPeriode", prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search( + token, + xdate, + periodeid, + current_page, + search, + branchCode, + regionalId +) { + try { + var resp = await axios.post(URL + "Journaltukarfaktur/search", { + token: token, + xdate: xdate, + periodeid: periodeid, + current_page: current_page, + search: search, + branchCode: branchCode, + regionalId: regionalId + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertSales(branchCode, date, jurnalno) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertSales/${branchCode}/${date}?isregen=1&jurnalno=${jurnalno}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "Journaltukarfaktur/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "Journaltukarfaktur/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + "Journaltukarfaktur/getUserApproveLevel", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListingCOA(params) { + try { + var resp = await axios.post(URL + "Journaltukarfaktur/getListingCOA", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function requestEditJurnal(params) { + try { + const resp = await axios.post(URL + "JournalVerifEdit/requestEditJurnal", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + const data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditJurnal(params) { + try { + var resp = await axios.post(URL + "JournalVerifEdit/saveEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function changeJurnalToPosted(params) { + try { + var resp = await axios.post(URL + "Journaltukarfaktur/changeJurnalToPosted", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getTotalJurnalNotPostedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journaltukarfaktur/getTotalJurnalNotPostedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function closeJurnalPerPeriode(params) { + try { + var resp = await axios.post(URL + "Journaltukarfaktur/closeJurnalPerPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataJurnalNotClosedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journaltukarfaktur/getDataJurnalNotClosedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogCloseJurnal.vue b/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogCloseJurnal.vue new file mode 100644 index 0000000..417ffbb --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogCloseJurnal.vue @@ -0,0 +1,76 @@ + + + diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogEditJurnal.vue b/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogEditJurnal.vue new file mode 100644 index 0000000..ef6cc9a --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogEditJurnal.vue @@ -0,0 +1,252 @@ + + + diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogPostingJurnal.vue b/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogPostingJurnal.vue new file mode 100644 index 0000000..0ae425c --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogPostingJurnal.vue @@ -0,0 +1,68 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogRequestEditJurnal.vue b/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogRequestEditJurnal.vue new file mode 100644 index 0000000..4df0f1e --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/components/dialogRequestEditJurnal.vue @@ -0,0 +1,60 @@ + + + diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/components/oneMediaJournalList.vue b/test/vuex/acc-one-jurnal-tukar-faktur/components/oneMediaJournalList.vue new file mode 100644 index 0000000..7ebf9b7 --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/components/oneMediaJournalList.vue @@ -0,0 +1,1226 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/index.php b/test/vuex/acc-one-jurnal-tukar-faktur/index.php new file mode 100644 index 0000000..a736dd6 --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/modules/journal.js b/test/vuex/acc-one-jurnal-tukar-faktur/modules/journal.js new file mode 100644 index 0000000..aba5e33 --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/modules/journal.js @@ -0,0 +1,607 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js"; + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: "new", + save_status: 0, + save_error_message: "", + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format("YYYY-MM-DD"), + end_date: moment(new Date()).format("YYYY-MM-DD"), + journals: [ + // { + // "journalID": "1", + // "journalNo": "JM002/08", + // "date": "31-08-2024", + // "name": "budhi/budhi", + // "account": "508501001", + // "title": "MS BESIN, SOLAR, PARKIR, TOL, TRANSPORT", + // "description": "ACCRUED PARKIR AGST 24", + // "debit": "275000", + // "credit": "0", + // "posted": "Y" + // }, + // { + // "journalID": "2", + // "journalNo": "JM002/08", + // "date": "31-08-2024", + // "name": "budhi/budhi", + // "account": "2004009", + // "title": "ACCRUED EXP OTHERS", + // "description": "ACCRUED PARKIR AGST 24", + // "debit": "0", + // "credit": "275000", + // "posted": "Y" + // } + ], + selected_journal: {}, + summary: { debit: 0, credit: 0, balance: 0 }, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + autocomplete_status: 0, + search_status: 0, + total_journal: 0, + user: one_user(), + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: [], + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + xsearch: "", + open_dialog_info: false, + msg_info: "", + + // -- + dialog_edit_journal: false, + user_level: {}, + list_coa: [], + journal_edit: [], + dialog_confirm_posting: false, + total_jurnal_not_posted: [], + dialog_request_edit: false, + + // --- + dialog_close_jurnal: false, + jurnal_to_close: [] + }, + mutations: { + update_search_status(state, val) { + state.search_status = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_last_id(state, val) { + state.last_id = val; + }, + update_coas(state, val) { + state.coas = val; + }, + update_total_coas(state, val) { + state.total_coas = val; + }, + update_selected_coa(state, val) { + state.selected_coa = val; + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val; + }, + update_act(state, val) { + state.act = val; + }, + update_save_status(state, val) { + state.save_status = val; + }, + update_save_error_message(state, val) { + state.save_error_message = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_msg_success(state, val) { + state.msg_success = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_dialog_error(state, val) { + state.dialog_error = val; + }, + update_open_print(state, value) { + state.open_print = value; + }, + + // --- + update_xdate(state, val) { + state.xdate = val; + }, + update_end_date(state, val) { + state.end_date = val; + }, + update_journals(state, val) { + state.journals = val; + }, + update_selected_journal(state, val) { + state.selected_journal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val; + }, + update_periodeList(state, val) { + state.periodeList = val; + }, + update_selected_periode(state, val) { + state.selected_periode = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val; + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_total_journal(state, val) { + state.total_journal = val; + }, + update_user(state, val) { + state.user = val; + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val; + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val; + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val; + }, + update_regionals(state, val) { + state.regionals = val; + }, + update_selected_regional(state, val) { + state.selected_regional = val; + }, + update_branchs(state, val) { + state.branchs = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.current_page = 1; + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val; + }, + update_msg_info(state, val) { + state.msg_info = val; + }, + + // -- + update_dialog_edit_journal(state, val) { + state.dialog_edit_journal = val; + }, + update_user_level(state, val) { + state.user_level = val; + }, + update_list_coa(state, val) { + state.list_coa = val; + }, + update_journal_edit(state, val) { + state.journal_edit = val; + }, + update_dialog_confirm_posting(state, val) { + state.dialog_confirm_posting = val; + }, + update_total_jurnal_not_posted(state, val) { + state.total_jurnal_not_posted = val; + }, + update_dialog_request_edit(state, val) { + state.dialog_request_edit = val; + }, + + update_dialog_close_jurnal(state, val) { + state.dialog_close_jurnal = val; + }, + update_jurnal_to_close(state, val) { + state.jurnal_to_close = val; + } + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1); + try { + let prm = {}; + prm.token = one_token(); + let resp = await api.getPeriode(prm); + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_autocomplete_status", 2); + let data = resp.data; + context.commit("update_periodeList", resp.data); + + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find( + (p) => + p.periodeMonth == currentMonth.toString() && + p.periodeYear == currentYear + ); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode); + } + } catch (e) { + context.commit("update_autocomplete_status", 3); + } + }, + async search(context, prm) { + context.commit("update_search_status", 1); + try { + let resp = await api.search( + one_token(), + prm.xdate, + prm.periodeid, + prm.current_page, + prm.search, + prm.branchCode, + prm.regionalId + ); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total + }; + + context.commit("update_journals", data.records); + context.commit("update_total_journal", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async insertSales(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalno = prm.jurnalno; + let resp = await api.insertSales(branchCode, date, jurnalno); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getRegional(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getRegional({ + token: one_token(), + regionalId: context.state.user.S_RegionalID + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_regionals", data.records); + context.commit("update_selected_regional", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async getBranch(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getBranch({ + token: one_token(), + regionalId: context.state.selected_regional.S_RegionalID, + branchCode: context.state.user.M_BranchCode + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_branchs", data.records); + context.commit("update_selected_branch", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async postingJurnal(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.changeJurnalToPosted(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_total_jurnal_not_posted", []); + context.commit("update_dialog_confirm_posting", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getUserApprovalLevel(context) { + try { + let param = { token: one_token() }; + const resp = await api.getUserApproveLevel(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getListingCOA(context) { + try { + let param = { + token: one_token(), + keyword: "" + }; + const resp = await api.getListingCOA(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_list_coa", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async requestEditJurnal(context) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + staffID: context.state.user.M_UserID, + staffName: context.state.user.M_UserUsername + }; + const resp = await api.requestEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + context.commit("update_dialog_request_edit", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async saveEditJurnal(context, newdetail) { + try { + let param = { + token: one_token(), + jurnalID: detail[0].jurnalID, + jurnalRequestEditID: context.state.selected_journal.JurnalRequestEditID, + oldjurnaltx: context.state.selected_journal.detailtx, + newjurnaltx: newdetail + }; + const resp = await api.saveEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_dialog_edit_journal", false); + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async totalJurnalNotPostedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getTotalJurnalNotPostedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_total_jurnal_not_posted", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getDataJurnalNotClosedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getDataJurnalNotClosedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_jurnal_to_close", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async closeJurnalPerPeriode(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.closeJurnalPerPeriode(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_jurnal_to_close", []); + context.commit("update_dialog_close_jurnal", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + } + } +}; diff --git a/test/vuex/acc-one-jurnal-tukar-faktur/store.js b/test/vuex/acc-one-jurnal-tukar-faktur/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-jurnal-tukar-faktur/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-verifikasi-edit/api/api.js b/test/vuex/acc-one-jurnal-verifikasi-edit/api/api.js new file mode 100644 index 0000000..1ef35de --- /dev/null +++ b/test/vuex/acc-one-jurnal-verifikasi-edit/api/api.js @@ -0,0 +1,115 @@ +const URL = "/one-api/mockup/masterdata/accounting/JournalVerifEdit/"; + +export async function getListJournalEdit(params) { + try { + var resp = await axios.post(URL + "getListJournalEdit", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getDetailJournalEdit(params) { + try { + var resp = await axios.post(URL + "getDetailJournalEdit", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function verifEditJurnal(params) { + try { + var resp = await axios.post(URL + "verifEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getListPeriode(params) { + try { + var resp = await axios.post(URL + "getListPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getListTypeJurnal(params) { + try { + var resp = await axios.post(URL + "getListTypeJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function updateRequestEditStatus(params) { + try { + var resp = await axios.post(URL + "updateRequestEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + var data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-verifikasi-edit/components/daftarVerifikasiJournal.vue b/test/vuex/acc-one-jurnal-verifikasi-edit/components/daftarVerifikasiJournal.vue new file mode 100644 index 0000000..efe7db4 --- /dev/null +++ b/test/vuex/acc-one-jurnal-verifikasi-edit/components/daftarVerifikasiJournal.vue @@ -0,0 +1,283 @@ + + + diff --git a/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogRequestEdit.vue b/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogRequestEdit.vue new file mode 100644 index 0000000..cb8aecb --- /dev/null +++ b/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogRequestEdit.vue @@ -0,0 +1,59 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogSelectPeriode.vue b/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogSelectPeriode.vue new file mode 100644 index 0000000..bfcd75e --- /dev/null +++ b/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogSelectPeriode.vue @@ -0,0 +1,91 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogVerfikasiEdit.vue b/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogVerfikasiEdit.vue new file mode 100644 index 0000000..ce1d6b5 --- /dev/null +++ b/test/vuex/acc-one-jurnal-verifikasi-edit/components/dialogVerfikasiEdit.vue @@ -0,0 +1,244 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal-verifikasi-edit/index.php b/test/vuex/acc-one-jurnal-verifikasi-edit/index.php new file mode 100644 index 0000000..cc63f4b --- /dev/null +++ b/test/vuex/acc-one-jurnal-verifikasi-edit/index.php @@ -0,0 +1,70 @@ + + + + + + + One + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/acc-one-jurnal-verifikasi-edit/modules/journal.js b/test/vuex/acc-one-jurnal-verifikasi-edit/modules/journal.js new file mode 100644 index 0000000..3fa118d --- /dev/null +++ b/test/vuex/acc-one-jurnal-verifikasi-edit/modules/journal.js @@ -0,0 +1,244 @@ +import * as api from '../api/api.js' + +export default { + namespaced: true, + state: { + snacbar: { + message: '', + color: 'success', + active: false + }, + filter: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + typejournal_id: 0, + search: '', + periode_id: 0, + }, + list_jurnaltype: [], + list_periode: [], + selected_periode: {}, + listjournal: { + records: [], + total: 0 + }, + currpage: 1, + selected_jurnal: {}, + selected_jurnal_detail: {}, + summary_jurnal_detail: { + total_debit: 0, + total_kredit: 0, + balance: 0 + }, + dialog_verifikasi: false, + dialog_pick_periode: false, + dialog_edit_request: false + }, + mutations: { + update_filter(state, val) { + state.filter = val + }, + update_list_jurnaltype(state, val) { + state.list_jurnaltype = val + }, + update_list_periode(state, val) { + state.list_periode = val + }, + update_selected_periode(state, val) { + state.selected_periode = val + }, + update_listjournal(state, val) { + state.listjournal = val + }, + update_currpage(state, val) { + state.currpage = val + }, + update_selected_jurnal(state, val) { + state.selected_jurnal = val + }, + update_selected_jurnal_detail(state, val) { + state.selected_jurnal_detail = val + }, + update_summary_jurnal_detail(state, val) { + state.summary_jurnal_detail = val + }, + update_dialog_verifikasi(state, val) { + state.dialog_verifikasi = val + }, + update_snacbar(state, val) { + state.snacbar = val + }, + update_dialog_pick_periode(state, val) { + state.dialog_pick_periode = val + }, + update_dialog_edit_request(state, val) { + state.dialog_edit_request = val + } + }, + actions: { + async getListPeriode(context) { + try { + let snac = { color: 'error', message: '', active: false }; + context.commit("update_snacbar", snac); + + var resp = await api.getListPeriode({token: one_token()}); + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit("update_snacbar", snac); + } else { + context.commit("update_list_periode", resp.data); + + // update to latest periode id in masterdata + let filter = context.state.filter + filter.periode_id = resp.data[0].periodeID + context.commit("update_filter", filter); + context.commit("update_selected_periode", resp.data[0]); + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit("update_snacbar", snac); + } + }, + async getListTypeJurnal(context) { + try { + let snac = { color: 'error', message: '', active: false }; + context.commit("update_snacbar", snac); + + var resp = await api.getListTypeJurnal({token: one_token()}); + if (resp.status != 'OK') { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit("update_snacbar", snac); + } else { + context.commit("update_list_jurnaltype", resp.data); + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit("update_snacbar", snac); + } + }, + async getListJournalEdit(context) { + try { + let snac = { color: 'error', message: '', active: false }; + context.commit("update_snacbar", snac); + + let param = { + periodeID: context.state.filter.periode_id, + typeJournalID: context.state.filter.typejournal_id, + search: context.state.filter.search, + startdate: context.state.filter.startdate, + enddate: context.state.filter.enddate, + page: context.state.currpage, + token: one_token() + } + var resp = await api.getListJournalEdit(param); + if (resp.status != "OK") { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit("update_snacbar", snac); + } else { + context.commit("update_listjournal", resp.data); + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit("update_snacbar", snac); + } + }, + async getDetailJournalEdit(context, jurnalid) { + try { + let snac = { color: 'error', message: '', active: false }; + context.commit("update_snacbar", snac); + + let param = { + jurnalID: jurnalid, + token: one_token() + } + var resp = await api.getDetailJournalEdit(param); + if (resp.status != "OK") { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit("update_snacbar", snac); + } else { + const data = resp.data; + context.commit("update_selected_jurnal_detail", data); + + // summary total kredit & debit jurnal + // changeAfter & changeBefore harusnya sama + const summary = data.changeAfter.reduce((acc, item) => { + const debit = Number(item.jurnalTxDebit) || 0; + const kredit = Number(item.jurnalTxCredit) || 0; + + acc.total_debit += debit; + acc.total_kredit += kredit; + return acc; + }, {total_debit: 0, total_kredit: 0}); + summary.balance = summary.total_debit - summary.total_kredit; + + context.commit("update_summary_jurnal_detail", summary); + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit("update_snacbar", snac); + } + }, + async updateRequestEditStatus(context, status) { + try { + let snac = { color: 'error', message: '', active: false }; + context.commit("update_snacbar", snac); + + let param = { + JurnalRequestEditID: context.state.selected_jurnal.JurnalRequestEditID, + jurnalID: context.state.selected_jurnal.jurnalID, + status: status.status, + token: one_token() + } + var resp = await api.updateRequestEditStatus(param); + if (resp.status != "OK") { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit("update_snacbar", snac); + } else { + context.dispatch("getListJournalEdit"); + let snac = { color: 'success', message: resp.data, active: true }; + context.commit("update_snacbar", snac); + + context.commit("update_dialog_edit_request", false) + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit("update_snacbar", snac); + } + }, + async verifEditJurnal(context, status) { + try { + let snac = { color: 'error', message: '', active: false }; + context.commit("update_snacbar", snac); + + let param = { + jurnalID: context.state.selected_jurnal.jurnalID, + newtrx: context.state.selected_jurnal_detail.changeAfter, + JurnalRequestEditID: context.state.selected_jurnal.JurnalRequestEditID, + status: status, + token: one_token() + } + var resp = await api.verifEditJurnal(param); + if (resp.status != "OK") { + let snac = { color: 'error', message: resp.message, active: true }; + context.commit("update_snacbar", snac); + } else { + context.dispatch("getListJournalEdit"); + let snac = { color: 'success', message: resp.data, active: true }; + context.commit("update_snacbar", snac); + + context.commit("update_summary_jurnal_detail", { + total_debit: 0, + total_kredit: 0, + balance: 0 + }); + context.commit("update_selected_jurnal_detail", {}); + context.commit("update_selected_jurnal", {}) + context.commit("update_dialog_verifikasi", false); + } + } catch (error) { + let snac = { color: 'error', message: error.message, active: true }; + context.commit("update_snacbar", snac); + } + } + } +} diff --git a/test/vuex/acc-one-jurnal-verifikasi-edit/store.js b/test/vuex/acc-one-jurnal-verifikasi-edit/store.js new file mode 100644 index 0000000..cf36f4a --- /dev/null +++ b/test/vuex/acc-one-jurnal-verifikasi-edit/store.js @@ -0,0 +1,11 @@ +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system: system + }, + state: {}, + mutations: {}, + actions: {} +}); diff --git a/test/vuex/acc-one-jurnal/api/jpbreg.js b/test/vuex/acc-one-jurnal/api/jpbreg.js new file mode 100644 index 0000000..65f7b7f --- /dev/null +++ b/test/vuex/acc-one-jurnal/api/jpbreg.js @@ -0,0 +1,184 @@ +const URL = "/one-api/mockup/masterdata/accounting/Jurnalsendreg"; + +export async function getJurnalType(prm) { + try { + var resp = await axios.post(URL + '/getJurnalType', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchPeriode(prm) { + try { + var resp = await axios.post(URL + '/searchPeriode', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchCoa(prm) { + try { + var resp = await axios.post(URL + '/searchCoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchCoaDetail(prm) { + try { + var resp = await axios.post(URL + '/searchCoaDetail', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchBranchPercent(prm) { + try { + var resp = await axios.post(URL + '/searchBranchPercent', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getDefaultBranch(prm) { + try { + var resp = await axios.post(URL + '/getBranch', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveJurnal(prm) { + try { + var resp = await axios.post(URL + '/saveJurnal', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function editJurnal(prm) { + try { + var resp = await axios.post(URL + '/editJurnal', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getDetail(prm) { + try { + var resp = await axios.post(URL + '/getDetail', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function deleteJurnal(prm) { + try { + var resp = await axios.post(URL + '/deleteJurnal', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/api/jurnalbiaya.js b/test/vuex/acc-one-jurnal/api/jurnalbiaya.js new file mode 100644 index 0000000..470a11a --- /dev/null +++ b/test/vuex/acc-one-jurnal/api/jurnalbiaya.js @@ -0,0 +1,165 @@ +// https://accone.aplikasi.web.id/one-api/mockup/masterdata/accounting/Jurnalgaji/searchCoa +const URL = "/one-api/mockup/masterdata/accounting/Jurnalbiaya"; + +export async function getJurnalType(prm) { + try { + var resp = await axios.post(URL + '/getJurnalType', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchPeriode(prm) { + try { + var resp = await axios.post(URL + '/searchPeriode', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchCoa(prm) { + try { + var resp = await axios.post(URL + '/searchCoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchCoaDetail(prm) { + try { + var resp = await axios.post(URL + '/searchCoaDetail', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchBranchPercent(prm) { + try { + var resp = await axios.post(URL + '/searchBranchPercent', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getDefaultBranch(prm) { + try { + var resp = await axios.post(URL + '/getBranch', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function saveJurnalBiaya(prm) { + try { + var resp = await axios.post(URL + '/saveJurnalBiaya', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getDetail(prm) { + try { + var resp = await axios.post(URL + '/getDetail', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function deleteJurnalBiaya(prm) { + try { + var resp = await axios.post(URL + '/deleteJurnalBiaya', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/api/jurnalgaji.js b/test/vuex/acc-one-jurnal/api/jurnalgaji.js new file mode 100644 index 0000000..97536a2 --- /dev/null +++ b/test/vuex/acc-one-jurnal/api/jurnalgaji.js @@ -0,0 +1,165 @@ +// https://accone.aplikasi.web.id/one-api/mockup/masterdata/accounting/Jurnalgaji/searchCoa +const URL = "/one-api/mockup/masterdata/accounting/Jurnalgaji"; + +export async function getJurnalType(prm) { + try { + var resp = await axios.post(URL + '/getJurnalType', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchPeriode(prm) { + try { + var resp = await axios.post(URL + '/searchPeriode', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchCoa(prm) { + try { + var resp = await axios.post(URL + '/searchCoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchCoaDetail(prm) { + try { + var resp = await axios.post(URL + '/searchCoaDetail', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchBranchPercent(prm) { + try { + var resp = await axios.post(URL + '/searchBranchPercent', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getDefaultBranch(prm) { + try { + var resp = await axios.post(URL + '/getBranch', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function saveJurnalGaji(prm) { + try { + var resp = await axios.post(URL + '/saveJurnalGaji', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getDetail(prm) { + try { + var resp = await axios.post(URL + '/getDetail', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function deleteJurnalgaji(prm) { + try { + var resp = await axios.post(URL + '/deleteJurnalgaji', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/api/jurnalumum.js b/test/vuex/acc-one-jurnal/api/jurnalumum.js new file mode 100644 index 0000000..43a440e --- /dev/null +++ b/test/vuex/acc-one-jurnal/api/jurnalumum.js @@ -0,0 +1,142 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + "jurnalumum/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getjurnaltype(prm) { + try { + var resp = await axios.post(URL + 'jurnalumum/getjurnaltype', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getperiode(token, prm) { + try { + var resp = await axios.post(URL + 'jurnalumum/getperiode', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchcoa(token, prm) { + try { + var resp = await axios.post(URL + 'jurnalumum/searchcoa', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function savejurnalumum(prm) { + try { + var resp = await axios.post(URL + 'jurnalumum/savejurnalumum', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editjurnalumum(prm) { + try { + var resp = await axios.post(URL + 'jurnalumum/editjurnalumum', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function deletejurnalumum(prm) { + try { + var resp = await axios.post(URL + 'jurnalumum/deletejurnalumum', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/api/pengeluaranbarang.js b/test/vuex/acc-one-jurnal/api/pengeluaranbarang.js new file mode 100644 index 0000000..81cd9e5 --- /dev/null +++ b/test/vuex/acc-one-jurnal/api/pengeluaranbarang.js @@ -0,0 +1,97 @@ +const URL = "/one-api/mockup/masterdata/accounting/jurnalpengeluaranbarang/" + +export async function get_periode(params) { + try { + var resp = await axios.post(URL + 'getperiode', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_coa(params) { + try { + var resp = await axios.post(URL + 'searchcoa', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function simpanjurnal(params) { + try { + var resp = await axios.post(URL + 'simpanjurnal', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getdetailjurnal(params) { + try { + var resp = await axios.post(URL + 'getdetailjurnal', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function editdetailjurnal(params) { + try { + var resp = await axios.post(URL + 'editjurnal', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/api/terimaBarang.js b/test/vuex/acc-one-jurnal/api/terimaBarang.js new file mode 100644 index 0000000..cff85ff --- /dev/null +++ b/test/vuex/acc-one-jurnal/api/terimaBarang.js @@ -0,0 +1,133 @@ +const URL = "/one-api/mockup/masterdata/accounting/Journalterimabarang"; + +export async function getJurnalType(prm) { + try { + var resp = await axios.post(URL + '/getTipeJurnal', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchPeriode(prm) { + try { + var resp = await axios.post(URL + '/getPeriode', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchSupplier(prm) { + try { + var resp = await axios.post(URL + '/getSupplier', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchCoa(prm) { + try { + var resp = await axios.post(URL + '/getCoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveJurnal(prm) { + try { + var resp = await axios.post(URL + '/createJurnal', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function loadEditDialog(prm) { + try { + var resp = await axios.post(URL + '/loadEditDialog', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function updateJurnal(prm) { + try { + var resp = await axios.post(URL + '/updateJurnal', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/components/JurnalPengirimanBarangRegional.vue b/test/vuex/acc-one-jurnal/components/JurnalPengirimanBarangRegional.vue new file mode 100644 index 0000000..8e0bf22 --- /dev/null +++ b/test/vuex/acc-one-jurnal/components/JurnalPengirimanBarangRegional.vue @@ -0,0 +1,1370 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal/components/accountDialogJurnalUmum.vue b/test/vuex/acc-one-jurnal/components/accountDialogJurnalUmum.vue new file mode 100644 index 0000000..1ab8410 --- /dev/null +++ b/test/vuex/acc-one-jurnal/components/accountDialogJurnalUmum.vue @@ -0,0 +1,921 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/components/accountOneJurnalList.vue b/test/vuex/acc-one-jurnal/components/accountOneJurnalList.vue new file mode 100644 index 0000000..27eebf5 --- /dev/null +++ b/test/vuex/acc-one-jurnal/components/accountOneJurnalList.vue @@ -0,0 +1,1066 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal/components/jurnalbiaya.vue b/test/vuex/acc-one-jurnal/components/jurnalbiaya.vue new file mode 100644 index 0000000..f2cee63 --- /dev/null +++ b/test/vuex/acc-one-jurnal/components/jurnalbiaya.vue @@ -0,0 +1,1530 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal/components/jurnalgaji.vue b/test/vuex/acc-one-jurnal/components/jurnalgaji.vue new file mode 100644 index 0000000..17b5158 --- /dev/null +++ b/test/vuex/acc-one-jurnal/components/jurnalgaji.vue @@ -0,0 +1,1525 @@ + + + + + diff --git a/test/vuex/acc-one-jurnal/components/pengeluaranBarangDialog.vue b/test/vuex/acc-one-jurnal/components/pengeluaranBarangDialog.vue new file mode 100644 index 0000000..536d1a6 --- /dev/null +++ b/test/vuex/acc-one-jurnal/components/pengeluaranBarangDialog.vue @@ -0,0 +1,629 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/components/terimaBarangForm.vue b/test/vuex/acc-one-jurnal/components/terimaBarangForm.vue new file mode 100644 index 0000000..8b34b5d --- /dev/null +++ b/test/vuex/acc-one-jurnal/components/terimaBarangForm.vue @@ -0,0 +1,1028 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/index.php b/test/vuex/acc-one-jurnal/index.php new file mode 100644 index 0000000..da4020d --- /dev/null +++ b/test/vuex/acc-one-jurnal/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/modules/jpbreg.js b/test/vuex/acc-one-jurnal/modules/jpbreg.js new file mode 100644 index 0000000..43039d4 --- /dev/null +++ b/test/vuex/acc-one-jurnal/modules/jpbreg.js @@ -0,0 +1,898 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/jpbreg.js" + +export default { + namespaced: true, + state: { + last_id: -1, + loading: false, + dialogForm: false, + dialogType: 'N', + startDate: moment(new Date()).format('YYYY-MM-DD'), + endDate: moment(new Date()).format('YYYY-MM-DD'), + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + user: one_user(), + jurnalTypeList: [], + selectedJurnalType: {}, + balance: { + debet: 0, + kredit: 0, + balance: 0, + }, + balanceRegional: { + debet: 0, + kredit: 0, + balance: 0, + }, + defaultJurnalType: {}, + loading: false, + periodeList: [], + searchPeriode: '', + selectedPeriode: {}, + loadingAutocomplete: false, + title: '', + coaList: [], + searchCoa: '', + selectedCoa: {}, + sallary: 0, + description: '', + branchPercentList: [], + selectedBranchPercent: {}, + defaultBranch: [], + detailJurnalGaji: [], + detailJurnalGajiRegional: [], + dialogAddDetail: false, + coaListDetail: [], + selectedCoaDetail: {}, + searchCoaDetail: '', + coaListKas: [], + selectedCoaKas: {}, + searchCoaKas: '', + selectedBranchDetail: {}, + kreditDetail: 0, + debetDetail: 0, + snackbar: { + state: false, + color: 'success', + msg: '' + }, + idEdit: 0, + isEdit: 'N', + jurnalNumber: "", + }, + mutations: { + update_jurnalNumber(state, val) { + state.jurnalNumber = val + }, + update_debetDetail(state, val) { + state.debetDetail = val + }, + update_dialogType(state, val) { + state.dialogType = val + }, + update_idEdit(state, val) { + state.idEdit = val + }, + update_balance(state, val) { + state.balance = val + }, + update_balanceRegional(state, val) { + state.balanceRegional = val + }, + update_snackbar(state, val) { + state.snackbar = val + }, + update_kreditDetail(state, val) { + state.kreditDetail = val + }, + update_selectedBranchDetail(state, val) { + state.selectedBranchDetail = val + }, + update_coaListKas(state, val) { + state.coaListKas = val + }, + update_searchCoaKas(state, val) { + state.searchCoaKas = val + }, + update_selectedCoaKas(state, val) { + state.selectedCoaKas = val + }, + update_coaListDetail(state, val) { + state.coaListDetail = val + }, + update_searchCoaDetail(state, val) { + state.searchCoaDetail = val + }, + update_selectedCoaDetail(state, val) { + state.selectedCoaDetail = val + }, + update_detailJurnalGaji(state, val) { + state.detailJurnalGaji = val + }, + update_detailJurnalGajiRegional(state, val) { + state.detailJurnalGajiRegional = val + }, + update_dialogAddDetail(state, val) { + state.dialogAddDetail = val + }, + update_title(state, val) { + state.title = val + }, + update_defaultBranch(state, val) { + state.defaultBranch = val + }, + update_branchPercentList(state, val) { + state.branchPercentList = val + }, + update_selectedBranchPercent(state, val) { + state.selectedBranchPercent = val + }, + update_selectedDate(state, val) { + state.selectedDate = val + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val + }, + update_coaList(state, val) { + state.coaList = val + }, + update_searchCoa(state, val) { + state.searchCoa = val + }, + update_selectedCoa(state, val) { + state.selectedCoa = val + }, + update_selectedPeriode(state, val) { + state.selectedPeriode = val + }, + update_searchPeriode(state, val) { + state.searchPeriode = val + }, + update_periodeList(state, val) { + state.periodeList = val + }, + update_loading(state, val) { + state.loading = val + }, + update_defaultJurnalType(state, val) { + state.defaultJurnalType = val + }, + update_selectedJurnalType(state, val) { + state.selectedJurnalType = val + }, + update_jurnalTypeList(state, val) { + state.jurnalTypeList = val + }, + update_dialogForm(state, val) { + state.dialogForm = val + }, + update_startDate(state, val) { + state.startDate = val + }, + update_endDate(state, val) { + state.endDate = val + }, + update_sallary(state, val) { + state.sallary = val + }, + update_description(state, val) { + state.description = val + }, + update_isEdit(state, val) { + state.isEdit = val + }, + }, + actions: { + countSummary(context) { + let kredit = 0; + let debet = 0; + context.state.detailJurnalGaji.forEach((e) => { + if (e.type === "D") { + debet = parseFloat(e.debet) + debet; + } + if (e.type === "K") { + kredit = parseFloat(e.kredit) + kredit; + } + }); + let total = debet - kredit; + + let summary = { + debet: debet, + kredit: kredit, + balance: total, + }; + context.commit("update_balance", summary) + // this.balance = summary; + }, + countSummaryRegional(context) { + let kredit = 0; + let debet = 0; + context.state.detailJurnalGajiRegional.forEach((e) => { + if (e.type === "D") { + debet = parseFloat(e.debet) + debet; + } + if (e.type === "K") { + kredit = parseFloat(e.kredit) + kredit; + } + }); + let total = debet - kredit; + + let summary = { + debet: debet, + kredit: kredit, + balance: total, + }; + context.commit("update_balanceRegional", summary) + + }, + async getDetail(context, prm) { + context.commit("update_loading", true) + try { + prm.token = one_token() + let resp = await api.getDetail(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp.data); + // setTimeout(() => { + // // Tambahkan logika yang ingin dijalankan setelah 3 detik di sini + // console.log("Timer selesai, menjalankan sesuatu setelah 3 detik"); + // context.commit("update_loading", false) + // }, 3000); + context.commit("update_selectedPeriode", resp.data.periode) + context.commit("update_searchPeriode", resp.data.periode.display) + context.commit("update_title", resp.data.title) + context.commit("update_selectedDate", resp.data.date) + // context.commit("update_selectedCoa", resp.data.coa) + // context.commit("update_searchCoa", resp.data.coa.display) + // context.commit("update_selectedCoaKas", resp.data.coaKas) + // context.commit("update_searchCoaKas", resp.data.coaKas.display ?? '') + // context.commit("update_sallary", resp.data.sallary) + context.commit("update_isEdit", resp.data.isEdit) + context.commit("update_jurnalNumber", resp.data.jurnal.jurnalNo) + context.commit("update_selectedBranchDetail", resp.data.destination) + context.commit("update_description", resp.data.description) + context.commit("update_detailJurnalGaji", resp.data.jurnalDetail) + // context.commit("update_detailJurnalGajiRegional", resp.data.jurnalDetailRegional) + // context.commit("update_dialogType", resp.data.type) + // context.commit("update_selectedBranchPercent", resp.data.branchPrecent) + context.dispatch("countSummary") + context.dispatch("countSummaryRegional") + context.commit("update_loading", false) + + // let snackbar = { + // state: true, + // color: 'success', + // msg: 'Berhasil tambah jurnal gaji regional' + // } + // context.commit("update_snackbar", snackbar) + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async saveJurnal(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.saveJurnal(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil tambah jurnal pengiriman barang ke cabang ' + prm.branchName + } + context.commit("update_snackbar", snackbar) + + context.commit("update_selectedPeriode", {}) + context.commit("update_selectedCoa", {}) + context.commit("update_selectedCoaDetail", {}) + context.commit("update_coaList", []) + context.commit("update_coaListKas", []) + context.commit("update_selectedCoaKas", {}) + context.commit("update_selectedBranchPercent", {}) + context.commit("update_selectedBranchDetail", {}) + + context.commit("update_detailJurnalGaji", []) + context.commit("update_detailJurnalGajiRegional", []) + context.commit("jurnalumum/update_x_drop_tipe_jurnal", {}, {root: true}); + + let blc = { + debet: 0, + kredit: 0, + balance: 0, + }; + context.commit("update_balance", blc) + context.commit("update_balanceRegional", blc) + context.commit("update_sallary", 0) + context.commit("update_searchCoa", '') + context.commit("update_searchCoaKas", '') + context.commit("update_title", '') + context.commit("update_description", '') + context.commit("update_dialogForm", false) + const jurnalumumState = context.rootState.jurnalumum; + + context.dispatch("jurnalumum/search", { + regionalid: jurnalumumState.user.S_RegionalID, + branchid: jurnalumumState.user.M_BranchID, + current_page: jurnalumumState.current_page, + search: jurnalumumState.x_search, + startdate: jurnalumumState.start_date, + enddate: jurnalumumState.end_date, + last_id: -1, + }, { root: true }); + + + // this.sallary = 0; + // this.searchCoa = ""; + // this.searchCoaKas = ""; + // this.title = ""; + // this.description = ""; + // console.log("close dialogs"); + // this.$emit("update:show", false); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async editJurnal(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.editJurnal(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil ubah jurnal pengiriman barang ke cabang ' + prm.branchName + } + context.commit("update_snackbar", snackbar) + + context.commit("update_selectedPeriode", {}) + context.commit("update_selectedCoa", {}) + context.commit("update_selectedCoaDetail", {}) + context.commit("update_coaList", []) + context.commit("update_coaListKas", []) + context.commit("update_selectedCoaKas", {}) + context.commit("update_selectedBranchPercent", {}) + context.commit("update_selectedBranchDetail", {}) + + context.commit("update_detailJurnalGaji", []) + context.commit("update_detailJurnalGajiRegional", []) + context.commit("jurnalumum/update_x_drop_tipe_jurnal", {}, {root: true}); + + let blc = { + debet: 0, + kredit: 0, + balance: 0, + }; + context.commit("update_balance", blc) + context.commit("update_balanceRegional", blc) + context.commit("update_sallary", 0) + context.commit("update_searchCoa", '') + context.commit("update_searchCoaKas", '') + context.commit("update_title", '') + context.commit("update_description", '') + const jurnalumumState = context.rootState.jurnalumum; + + context.dispatch("jurnalumum/search", { + regionalid: jurnalumumState.user.S_RegionalID, + branchid: jurnalumumState.user.M_BranchID, + current_page: jurnalumumState.current_page, + search: jurnalumumState.x_search, + startdate: jurnalumumState.start_date, + enddate: jurnalumumState.end_date, + last_id: -1, + }, { root: true }); + context.commit("update_dialogForm", false) + + + // this.sallary = 0; + // this.searchCoa = ""; + // this.searchCoaKas = ""; + // this.title = ""; + // this.description = ""; + // console.log("close dialogs"); + // this.$emit("update:show", false); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async getJurnalType(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getJurnalType(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_jurnalTypeList", resp.data.records) + context.commit("update_selectedJurnalType", resp.data.default) + context.commit("update_defaultJurnalType", resp.data.default) + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async getDefaultBranch(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + let resp = await api.getDefaultBranch(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_defaultBranch", resp.data) + // context.commit("update_selectedJurnalType", resp.data.default) + // context.commit("update_defaultJurnalType", resp.data.default) + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async deleteJurnal(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.deleteJurnal(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil delete jurnal gaji regional' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_snackbar", snackbar) + + context.commit("update_selectedPeriode", {}) + context.commit("update_selectedCoa", {}) + context.commit("update_selectedCoaDetail", {}) + context.commit("update_coaList", []) + context.commit("update_coaListKas", []) + context.commit("update_selectedCoaKas", {}) + context.commit("update_selectedBranchPercent", {}) + context.commit("update_selectedBranchDetail", {}) + + context.commit("update_detailJurnalGaji", []) + context.commit("update_detailJurnalGajiRegional", []) + + let blc = { + debet: 0, + kredit: 0, + balance: 0, + }; + context.commit("update_balance", blc) + context.commit("update_balanceRegional", blc) + context.commit("update_sallary", 0) + context.commit("update_searchCoa", '') + context.commit("update_searchCoaKas", '') + context.commit("update_title", '') + context.commit("update_description", '') + context.commit("update_dialogForm", false) + + const jurnalumumState = context.rootState.jurnalumum; + + context.dispatch("jurnalumum/search", { + regionalid: jurnalumumState.user.S_RegionalID, + branchid: jurnalumumState.user.M_BranchID, + current_page: jurnalumumState.current_page, + search: jurnalumumState.x_search, + startdate: jurnalumumState.start_date, + enddate: jurnalumumState.end_date, + last_id: -1, + }, { root: true }); + + + + + // this.sallary = 0; + // this.searchCoa = ""; + // this.searchCoaKas = ""; + // this.title = ""; + // this.description = ""; + // console.log("close dialogs"); + // this.$emit("update:show", false); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async getBranchpercent(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + prm.regional = context.state.user.S_RegionalID + let resp = await api.searchBranchPercent(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_branchPercentList", resp.data) + // context.commit("update_selectedJurnalType", resp.data.default) + // context.commit("update_defaultJurnalType", resp.data.default) + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async getPeriode(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchPeriode; + prm.token = one_token() + let resp = await api.searchPeriode(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_periodeList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoa(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoa; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoaKas(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoaKas; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaListKas", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoaDetail(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoaDetail; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + prm.branch = context.state.selectedBranchDetail.branchID + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaListDetail", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async searchKredit(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchKredit; + prm.token = one_token() + let resp = await api.searchkredit(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_kreditList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async search(context) { + context.commit("update_loading", true) + try { + let prm = {} + prm.search = context.state.searchTemplate + prm.page = context.state.page + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + } else { + context.commit("update_loading", false) + context.commit("update_templateList", resp.data.records) + context.commit("update_total", resp.data.total) + console.log(resp.data); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async insertTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.insertTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogForm", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil tambah data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error add data' + } + context.commit("update_snackbar", snackbar) + console.log('error add data') + } + }, + async updateTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.updateTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogForm", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil edit data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error edit data' + } + context.commit("update_snackbar", snackbar) + console.log('error edit data') + } + }, + async deleteTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.deleteTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogAlert", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil delete data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error edit data' + } + context.commit("update_snackbar", snackbar) + console.log('error delete data') + } + }, + + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/modules/jurnalbiaya.js b/test/vuex/acc-one-jurnal/modules/jurnalbiaya.js new file mode 100644 index 0000000..8f4fc38 --- /dev/null +++ b/test/vuex/acc-one-jurnal/modules/jurnalbiaya.js @@ -0,0 +1,821 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/jurnalbiaya.js" + +export default { + namespaced: true, + state: { + last_id: -1, + loading: false, + dialogForm: false, + dialogType: 'N', + startDate: moment(new Date()).format('YYYY-MM-DD'), + endDate: moment(new Date()).format('YYYY-MM-DD'), + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + user: one_user(), + jurnalTypeList: [], + selectedJurnalType: {}, + balance: { + debet: 0, + kredit: 0, + balance: 0, + }, + balanceRegional: { + debet: 0, + kredit: 0, + balance: 0, + }, + defaultJurnalType: {}, + loading: false, + periodeList: [], + searchPeriode: '', + selectedPeriode: {}, + loadingAutocomplete: false, + title: '', + coaList: [], + searchCoa: '', + selectedCoa: {}, + costs: 0, + description: '', + branchCostPercentList: [], + selectedBranchCostPercent: {}, + defaultBranch: [], + detailJurnalBiaya: [], + detailJurnalBiayaRegional: [], + dialogAddDetail: false, + coaListDetail: [], + selectedCoaDetail: {}, + searchCoaDetail: '', + coaListKas: [], + selectedCoaKas: {}, + searchCoaKas: '', + coaListReg: [], + selectedCoaReg: {}, + searchCoaReg: '', + selectedBranchDetail: {}, + kreditDetail: 0, + snackbar: { + state: false, + color: 'success', + msg: '' + }, + idEdit: 0, + }, + mutations: { + update_dialogType(state, val) { + state.dialogType = val + }, + update_idEdit(state, val) { + state.idEdit = val + }, + update_balance(state, val) { + state.balance = val + }, + update_balanceRegional(state, val) { + state.balanceRegional = val + }, + update_snackbar(state, val) { + state.snackbar = val + }, + update_kreditDetail(state, val) { + state.kreditDetail = val + }, + update_selectedBranchDetail(state, val) { + state.selectedBranchDetail = val + }, + update_coaListKas(state, val) { + state.coaListKas = val + }, + update_searchCoaKas(state, val) { + state.searchCoaKas = val + }, + update_selectedCoaKas(state, val) { + state.selectedCoaKas = val + }, + update_coaListReg(state, val) { + state.coaListReg = val + }, + update_searchCoaReg(state, val) { + state.searchCoaReg = val + }, + update_selectedCoaReg(state, val) { + state.selectedCoaReg = val + }, + update_coaListDetail(state, val) { + state.coaListDetail = val + }, + update_searchCoaDetail(state, val) { + state.searchCoaDetail = val + }, + update_selectedCoaDetail(state, val) { + state.selectedCoaDetail = val + }, + update_detailJurnalBiaya(state, val) { + state.detailJurnalBiaya = val + }, + update_detailJurnalBiayaRegional(state, val) { + state.detailJurnalBiayaRegional = val + }, + update_dialogAddDetail(state, val) { + state.dialogAddDetail = val + }, + update_title(state, val) { + state.title = val + }, + update_defaultBranch(state, val) { + state.defaultBranch = val + }, + update_branchCostPercentList(state, val) { + state.branchCostPercentList = val + }, + update_selectedBranchCostPercent(state, val) { + state.selectedBranchCostPercent = val + }, + update_selectedDate(state, val) { + state.selectedDate = val + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val + }, + update_coaList(state, val) { + state.coaList = val + }, + update_searchCoa(state, val) { + state.searchCoa = val + }, + update_selectedCoa(state, val) { + state.selectedCoa = val + }, + update_selectedPeriode(state, val) { + state.selectedPeriode = val + }, + update_searchPeriode(state, val) { + state.searchPeriode = val + }, + update_periodeList(state, val) { + state.periodeList = val + }, + update_loading(state, val) { + state.loading = val + }, + update_defaultJurnalType(state, val) { + state.defaultJurnalType = val + }, + update_selectedJurnalType(state, val) { + state.selectedJurnalType = val + }, + update_jurnalTypeList(state, val) { + state.jurnalTypeList = val + }, + update_dialogForm(state, val) { + state.dialogForm = val + }, + update_startDate(state, val) { + state.startDate = val + }, + update_endDate(state, val) { + state.endDate = val + }, + update_costs(state, val) { + state.costs = val + }, + update_description(state, val) { + state.description = val + }, + }, + actions: { + countSummary(context) { + let kredit = 0; + let debet = 0; + context.state.detailJurnalBiaya.forEach((e) => { + if (e.type === "D") { + debet = parseFloat(e.debet) + debet; + } + if (e.type === "K") { + kredit = parseFloat(e.kredit) + kredit; + } + }); + let total = debet - kredit; + + let summary = { + debet: debet, + kredit: kredit, + balance: total, + }; + context.commit("update_balance", summary) + // this.balance = summary; + }, + countSummaryRegional(context) { + let kredit = 0; + let debet = 0; + context.state.detailJurnalBiayaRegional.forEach((e) => { + if (e.type === "D") { + debet = parseFloat(e.debet) + debet; + } + if (e.type === "K") { + kredit = parseFloat(e.kredit) + kredit; + } + }); + let total = debet - kredit; + + let summary = { + debet: debet, + kredit: kredit, + balance: total, + }; + context.commit("update_balanceRegional", summary) + + }, + async getDetail(context, prm) { + context.commit("update_loading", true) + try { + prm.token = one_token() + let resp = await api.getDetail(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp.data); + // setTimeout(() => { + // // Tambahkan logika yang ingin dijalankan setelah 3 detik di sini + // console.log("Timer selesai, menjalankan sesuatu setelah 3 detik"); + // context.commit("update_loading", false) + // }, 3000); + context.commit("update_selectedPeriode", resp.data.periode) + context.commit("update_searchPeriode", resp.data.periode.display) + context.commit("update_title", resp.data.title) + context.commit("update_selectedDate", resp.data.date) + context.commit("update_selectedCoa", resp.data.coa) + context.commit("update_searchCoa", resp.data.coa.display) + context.commit("update_selectedCoaKas", resp.data.coaKas) + context.commit("update_searchCoaKas", resp.data.coaKas.display ?? '') + context.commit("update_selectedCoaReg", resp.data.coaReg) + context.commit("update_searchCoaReg", resp.data.coaReg.display ?? '') + context.commit("update_costs", resp.data.costs) + context.commit("update_description", resp.data.description) + context.commit("update_detailJurnalBiaya", resp.data.jurnalDetail) + context.commit("update_detailJurnalBiayaRegional", resp.data.jurnalDetailRegional) + context.commit("update_dialogType", resp.data.type) + context.commit("update_selectedBranchCostPercent", resp.data.branchPrecent) + context.dispatch("countSummary") + context.dispatch("countSummaryRegional") + context.commit("update_loading", false) + + // let snackbar = { + // state: true, + // color: 'success', + // msg: 'Berhasil tambah jurnal gaji regional' + // } + // context.commit("update_snackbar", snackbar) + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async saveJurnalBiaya(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.saveJurnalBiaya(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil tambah jurnal biaya regional' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_selectedPeriode", {}) + context.commit("update_selectedCoa", {}) + context.commit("update_coaList", []) + context.commit("update_coaListKas", []) + context.commit("update_selectedCoaKas", {}) + context.commit("update_selectedBranchCostPercent", {}) + + context.commit("update_detailJurnalBiaya", []) + context.commit("update_detailJurnalBiayaRegional", []) + + let blc = { + debet: 0, + kredit: 0, + balance: 0, + }; + context.commit("update_balance", blc) + context.commit("update_balanceRegional", blc) + context.commit("update_costs", 0) + context.commit("update_searchCoa", '') + context.commit("update_searchCoaKas", '') + context.commit("update_searchCoaReg", '') + context.commit("update_title", '') + context.commit("update_description", '') + context.commit("update_dialogForm", false) + context.commit("jurnalumum/update_x_drop_tipe_jurnal", {}, {root: true}); + const jurnalumumState = context.rootState.jurnalumum; + + context.dispatch("jurnalumum/search", { + regionalid: jurnalumumState.user.S_RegionalID, + branchid: jurnalumumState.user.M_BranchID, + current_page: jurnalumumState.current_page, + search: jurnalumumState.x_search, + startdate: jurnalumumState.start_date, + enddate: jurnalumumState.end_date, + last_id: -1, + }, { root: true }); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async deleteJurnalBiaya(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.deleteJurnalBiaya(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil delete jurnal biaya regional' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_selectedPeriode", {}) + context.commit("update_selectedCoa", {}) + context.commit("update_coaList", []) + context.commit("update_coaListKas", []) + context.commit("update_selectedCoaKas", {}) + context.commit("update_selectedBranchCostPercent", {}) + + context.commit("update_detailJurnalBiaya", []) + context.commit("update_detailJurnalBiayaRegional", []) + + let blc = { + debet: 0, + kredit: 0, + balance: 0, + }; + + const jurnalumumState = context.rootState.jurnalumum; + + context.dispatch("jurnalumum/search", { + regionalid: jurnalumumState.user.S_RegionalID, + branchid: jurnalumumState.user.M_BranchID, + current_page: jurnalumumState.current_page, + search: jurnalumumState.x_search, + startdate: jurnalumumState.start_date, + enddate: jurnalumumState.end_date, + last_id: -1, + }, { root: true }); + + + + + // this.costs = 0; + // this.searchCoa = ""; + // this.searchCoaKas = ""; + // this.title = ""; + // this.description = ""; + // console.log("close dialogs"); + // this.$emit("update:show", false); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async getJurnalType(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getJurnalType(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_jurnalTypeList", resp.data.records) + context.commit("update_selectedJurnalType", resp.data.default) + context.commit("update_defaultJurnalType", resp.data.default) + + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async getDefaultBranch(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + let resp = await api.getDefaultBranch(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_defaultBranch", resp.data) + // context.commit("update_selectedJurnalType", resp.data.default) + // context.commit("update_defaultJurnalType", resp.data.default) + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async getBranchpercent(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + prm.regional = context.state.user.S_RegionalID + let resp = await api.searchBranchPercent(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_branchCostPercentList", resp.data) + // context.commit("update_selectedJurnalType", resp.data.default) + // context.commit("update_defaultJurnalType", resp.data.default) + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async getPeriode(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchPeriode; + prm.token = one_token() + let resp = await api.searchPeriode(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_periodeList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoa(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoa; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoaKas(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoaKas; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaListKas", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoaReg(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoaReg; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaListReg", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoaDetail(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoaDetail; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + prm.branch = context.state.selectedBranchDetail.branchID + prm.token = one_token() + let resp = await api.searchCoaDetail(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaListDetail", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async searchKredit(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchKredit; + prm.token = one_token() + let resp = await api.searchkredit(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_kreditList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async search(context) { + context.commit("update_loading", true) + try { + let prm = {} + prm.search = context.state.searchTemplate + prm.page = context.state.page + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + } else { + context.commit("update_loading", false) + context.commit("update_templateList", resp.data.records) + context.commit("update_total", resp.data.total) + console.log(resp.data); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async insertTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.insertTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogForm", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil tambah data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error add data' + } + context.commit("update_snackbar", snackbar) + console.log('error add data') + } + }, + async updateTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.updateTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogForm", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil edit data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error edit data' + } + context.commit("update_snackbar", snackbar) + console.log('error edit data') + } + }, + async deleteTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.deleteTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogAlert", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil delete data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error edit data' + } + context.commit("update_snackbar", snackbar) + console.log('error delete data') + } + }, + + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/modules/jurnalgaji.js b/test/vuex/acc-one-jurnal/modules/jurnalgaji.js new file mode 100644 index 0000000..dda61fe --- /dev/null +++ b/test/vuex/acc-one-jurnal/modules/jurnalgaji.js @@ -0,0 +1,841 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/jurnalgaji.js" + +export default { + namespaced: true, + state: { + last_id: -1, + loading: false, + dialogForm: false, + dialogType: 'N', + startDate: moment(new Date()).format('YYYY-MM-DD'), + endDate: moment(new Date()).format('YYYY-MM-DD'), + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + user: one_user(), + jurnalTypeList: [], + selectedJurnalType: {}, + balance: { + debet: 0, + kredit: 0, + balance: 0, + }, + balanceRegional: { + debet: 0, + kredit: 0, + balance: 0, + }, + defaultJurnalType: {}, + loading: false, + periodeList: [], + searchPeriode: '', + selectedPeriode: {}, + loadingAutocomplete: false, + title: '', + coaList: [], + searchCoa: '', + selectedCoa: {}, + sallary: 0, + description: '', + branchPercentList: [], + selectedBranchPercent: {}, + defaultBranch: [], + detailJurnalGaji: [], + detailJurnalGajiRegional: [], + dialogAddDetail: false, + coaListDetail: [], + selectedCoaDetail: {}, + searchCoaDetail: '', + coaListKas: [], + selectedCoaKas: {}, + searchCoaKas: '', + coaListReg: [], + selectedCoaReg: {}, + searchCoaReg: '', + selectedBranchDetail: {}, + kreditDetail: 0, + snackbar: { + state: false, + color: 'success', + msg: '' + }, + idEdit: 0, + }, + mutations: { + update_dialogType(state, val) { + state.dialogType = val + }, + update_idEdit(state, val) { + state.idEdit = val + }, + update_balance(state, val) { + state.balance = val + }, + update_balanceRegional(state, val) { + state.balanceRegional = val + }, + update_snackbar(state, val) { + state.snackbar = val + }, + update_kreditDetail(state, val) { + state.kreditDetail = val + }, + update_selectedBranchDetail(state, val) { + state.selectedBranchDetail = val + }, + update_coaListKas(state, val) { + state.coaListKas = val + }, + update_searchCoaKas(state, val) { + state.searchCoaKas = val + }, + update_coaListReg(state, val) { + state.coaListReg = val + }, + update_searchCoaReg(state, val) { + state.searchCoaReg = val + }, + update_selectedCoaReg(state, val) { + state.selectedCoaReg = val + }, + update_selectedCoaKas(state, val) { + state.selectedCoaKas = val + }, + update_coaListDetail(state, val) { + state.coaListDetail = val + }, + update_searchCoaDetail(state, val) { + state.searchCoaDetail = val + }, + update_selectedCoaDetail(state, val) { + state.selectedCoaDetail = val + }, + update_detailJurnalGaji(state, val) { + state.detailJurnalGaji = val + }, + update_detailJurnalGajiRegional(state, val) { + state.detailJurnalGajiRegional = val + }, + update_dialogAddDetail(state, val) { + state.dialogAddDetail = val + }, + update_title(state, val) { + state.title = val + }, + update_defaultBranch(state, val) { + state.defaultBranch = val + }, + update_branchPercentList(state, val) { + state.branchPercentList = val + }, + update_selectedBranchPercent(state, val) { + state.selectedBranchPercent = val + }, + update_selectedDate(state, val) { + state.selectedDate = val + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val + }, + update_coaList(state, val) { + state.coaList = val + }, + update_searchCoa(state, val) { + state.searchCoa = val + }, + update_selectedCoa(state, val) { + state.selectedCoa = val + }, + update_selectedPeriode(state, val) { + state.selectedPeriode = val + }, + update_searchPeriode(state, val) { + state.searchPeriode = val + }, + update_periodeList(state, val) { + state.periodeList = val + }, + update_loading(state, val) { + state.loading = val + }, + update_defaultJurnalType(state, val) { + state.defaultJurnalType = val + }, + update_selectedJurnalType(state, val) { + state.selectedJurnalType = val + }, + update_jurnalTypeList(state, val) { + state.jurnalTypeList = val + }, + update_dialogForm(state, val) { + state.dialogForm = val + }, + update_startDate(state, val) { + state.startDate = val + }, + update_endDate(state, val) { + state.endDate = val + }, + update_sallary(state, val) { + state.sallary = val + }, + update_description(state, val) { + state.description = val + }, + }, + actions: { + countSummary(context) { + let kredit = 0; + let debet = 0; + context.state.detailJurnalGaji.forEach((e) => { + if (e.type === "D") { + debet = parseFloat(e.debet) + debet; + } + if (e.type === "K") { + kredit = parseFloat(e.kredit) + kredit; + } + }); + let total = debet - kredit; + + let summary = { + debet: debet, + kredit: kredit, + balance: total, + }; + context.commit("update_balance", summary) + // this.balance = summary; + }, + countSummaryRegional(context) { + let kredit = 0; + let debet = 0; + context.state.detailJurnalGajiRegional.forEach((e) => { + if (e.type === "D") { + debet = parseFloat(e.debet) + debet; + } + if (e.type === "K") { + kredit = parseFloat(e.kredit) + kredit; + } + }); + let total = debet - kredit; + + let summary = { + debet: debet, + kredit: kredit, + balance: total, + }; + context.commit("update_balanceRegional", summary) + + }, + async getDetail(context, prm) { + context.commit("update_loading", true) + try { + prm.token = one_token() + let resp = await api.getDetail(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp.data); + // setTimeout(() => { + // // Tambahkan logika yang ingin dijalankan setelah 3 detik di sini + // console.log("Timer selesai, menjalankan sesuatu setelah 3 detik"); + // context.commit("update_loading", false) + // }, 3000); + context.commit("update_selectedPeriode", resp.data.periode) + context.commit("update_searchPeriode", resp.data.periode.display) + context.commit("update_title", resp.data.title) + context.commit("update_selectedDate", resp.data.date) + context.commit("update_selectedCoa", resp.data.coa) + context.commit("update_searchCoa", resp.data.coa.display) + context.commit("update_selectedCoaKas", resp.data.coaKas) + context.commit("update_searchCoaKas", resp.data.coaKas.display ?? '') + context.commit("update_selectedCoaReg", resp.data.coaReg) + context.commit("update_searchCoaReg", resp.data.coaReg.display ?? '') + context.commit("update_sallary", resp.data.sallary) + context.commit("update_description", resp.data.description) + context.commit("update_detailJurnalGaji", resp.data.jurnalDetail) + context.commit("update_detailJurnalGajiRegional", resp.data.jurnalDetailRegional) + context.commit("update_dialogType", resp.data.type) + context.commit("update_selectedBranchPercent", resp.data.branchPrecent) + context.dispatch("countSummary") + context.dispatch("countSummaryRegional") + context.commit("update_loading", false) + + // let snackbar = { + // state: true, + // color: 'success', + // msg: 'Berhasil tambah jurnal gaji regional' + // } + // context.commit("update_snackbar", snackbar) + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async saveJurnalGaji(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.saveJurnalGaji(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil tambah jurnal gaji regional' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_selectedPeriode", {}) + context.commit("update_selectedCoa", {}) + context.commit("update_coaList", []) + context.commit("update_coaListKas", []) + context.commit("update_selectedCoaKas", {}) + context.commit("update_selectedBranchPercent", {}) + + context.commit("update_detailJurnalGaji", []) + context.commit("update_detailJurnalGajiRegional", []) + + let blc = { + debet: 0, + kredit: 0, + balance: 0, + }; + context.commit("update_balance", blc) + context.commit("update_balanceRegional", blc) + context.commit("update_sallary", 0) + context.commit("update_searchCoa", '') + context.commit("update_searchCoaKas", '') + context.commit("update_searchCoaReg", '') + context.commit("update_title", '') + context.commit("update_description", '') + context.commit("update_dialogForm", false) + context.commit("jurnalumum/update_x_drop_tipe_jurnal", {}, {root: true}); + const jurnalumumState = context.rootState.jurnalumum; + // console.log("Data Jurnal Umum:", jurnalumumState); + // this.$store.dispatch("jurnalumum/search", { + // regionalid: this.$store.state.jurnalumum.user.S_RegionalID, + // branchid: this.$store.state.jurnalumum.user.M_BranchID, + // current_page: this.$store.state.jurnalumum.current_page, + // search: this.$store.state.jurnalumum.x_search, + // startdate: this.$store.state.jurnalumum.start_date, + // enddate: this.$store.state.jurnalumum.end_date, + // last_id: -1, + // }); + context.dispatch("jurnalumum/search", { + regionalid: jurnalumumState.user.S_RegionalID, + branchid: jurnalumumState.user.M_BranchID, + current_page: jurnalumumState.current_page, + search: jurnalumumState.x_search, + startdate: jurnalumumState.start_date, + enddate: jurnalumumState.end_date, + last_id: -1, + }, { root: true }); + + + + + // this.sallary = 0; + // this.searchCoa = ""; + // this.searchCoaKas = ""; + // this.title = ""; + // this.description = ""; + // console.log("close dialogs"); + // this.$emit("update:show", false); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async deleteJurnalgaji(context, prm) { + context.commit("update_loading", true) + try { + + prm.token = one_token() + let resp = await api.deleteJurnalgaji(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + } else { + console.log(resp); + context.commit("update_loading", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil delete jurnal gaji regional' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_selectedPeriode", {}) + context.commit("update_selectedCoa", {}) + context.commit("update_coaList", []) + context.commit("update_coaListKas", []) + context.commit("update_selectedCoaKas", {}) + context.commit("update_selectedBranchPercent", {}) + + context.commit("update_detailJurnalGaji", []) + context.commit("update_detailJurnalGajiRegional", []) + + let blc = { + debet: 0, + kredit: 0, + balance: 0, + }; + + const jurnalumumState = context.rootState.jurnalumum; + + context.dispatch("jurnalumum/search", { + regionalid: jurnalumumState.user.S_RegionalID, + branchid: jurnalumumState.user.M_BranchID, + current_page: jurnalumumState.current_page, + search: jurnalumumState.x_search, + startdate: jurnalumumState.start_date, + enddate: jurnalumumState.end_date, + last_id: -1, + }, { root: true }); + + + + + // this.sallary = 0; + // this.searchCoa = ""; + // this.searchCoaKas = ""; + // this.title = ""; + // this.description = ""; + // console.log("close dialogs"); + // this.$emit("update:show", false); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + let snackbar = { + state: true, + color: 'error', + msg: e.message + } + context.commit("update_snackbar", snackbar) + } + }, + async getJurnalType(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getJurnalType(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_jurnalTypeList", resp.data.records) + context.commit("update_selectedJurnalType", resp.data.default) + context.commit("update_defaultJurnalType", resp.data.default) + + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async getDefaultBranch(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + let resp = await api.getDefaultBranch(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_defaultBranch", resp.data) + // context.commit("update_selectedJurnalType", resp.data.default) + // context.commit("update_defaultJurnalType", resp.data.default) + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async getBranchpercent(context) { + context.commit("update_loading", true) + try { + let prm = {}; + prm.token = one_token() + prm.regional = context.state.user.S_RegionalID + let resp = await api.searchBranchPercent(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loading", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_branchPercentList", resp.data) + // context.commit("update_selectedJurnalType", resp.data.default) + // context.commit("update_defaultJurnalType", resp.data.default) + + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async getPeriode(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchPeriode; + prm.token = one_token() + let resp = await api.searchPeriode(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_periodeList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoa(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoa; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoaKas(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoaKas; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaListKas", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoaReg(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoaReg; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaListReg", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async getCoaDetail(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoaDetail; + prm.company = context.state.user.M_BranchCompanyID + prm.regional = context.state.user.S_RegionalID + prm.branch = context.state.selectedBranchDetail.branchID + prm.token = one_token() + let resp = await api.searchCoaDetail(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_coaListDetail", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async searchKredit(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchKredit; + prm.token = one_token() + let resp = await api.searchkredit(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + console.log(resp); + } else { + console.log(resp); + context.commit("update_loadingAutocomplete", false) + // let cek = 0; + // if (parseInt(resp.data) > 0) { + // cek = true + // } + context.commit("update_kreditList", resp.data) + + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + async search(context) { + context.commit("update_loading", true) + try { + let prm = {} + prm.search = context.state.searchTemplate + prm.page = context.state.page + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_loading", false) + } else { + context.commit("update_loading", false) + context.commit("update_templateList", resp.data.records) + context.commit("update_total", resp.data.total) + console.log(resp.data); + } + } catch (e) { + context.commit("update_loading", false) + console.log(e) + } + }, + async insertTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.insertTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogForm", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil tambah data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error add data' + } + context.commit("update_snackbar", snackbar) + console.log('error add data') + } + }, + async updateTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.updateTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogForm", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil edit data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error edit data' + } + context.commit("update_snackbar", snackbar) + console.log('error edit data') + } + }, + async deleteTemplate(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.deleteTemplate(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.dispatch("search"); + context.commit("update_dialogAlert", false) + let snackbar = { + state: true, + color: 'success', + msg: 'Berhasil delete data' + } + context.commit("update_snackbar", snackbar) + + context.commit("update_loadingSave", false) + + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: 'Error edit data' + } + context.commit("update_snackbar", snackbar) + console.log('error delete data') + } + }, + + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/modules/jurnalumum.js b/test/vuex/acc-one-jurnal/modules/jurnalumum.js new file mode 100644 index 0000000..0008958 --- /dev/null +++ b/test/vuex/acc-one-jurnal/modules/jurnalumum.js @@ -0,0 +1,446 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/jurnalumum.js"; + +export default { + namespaced: true, + state: { + // state listing + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + jurnalumums: [], + total_jurnalumum: 0, + selected_jurnalumum: {}, + start_date: moment(new Date().getFullYear() + '-01-01').format('YYYY-MM-DD'), + end_date: moment(new Date()).format('YYYY-MM-DD'), + open_dialog_info: false, + msg_info: "", + drop_tipe_jurnal: [], + x_drop_tipe_jurnal: {}, + dialogjurnaltype: false, + open_print: false, + + // state jurnal umum + user: one_user(), + dialog_is_active: false, + loading_jurnaltype: false, + jurnaltypes: [], + selected_jurnaltype: {}, + selected_jurnaltype_u: {}, + xdate: moment(new Date()).format('YYYY-MM-DD'), + periodes: [], + selected_periode: {}, + autocomplete_status: 0, + dialogdetail: false, + coalist: [], + selected_coa: {}, + errors: [], + errors_save_jurnal: [], + xsummary: { "debit": 0, "credit": 0, "balance": 0 }, + open_dialog_detail_info: false, + msg_detail_info: "", + save_status: 0, + save_error_message: "", + alert_error: false, + alert_success: false, + msg_success: "", + act: "", + title: "", + deskripsi: "", + jurnaldetails: [], + selected_jurnaldetail: {}, + periodeStartDate: moment(new Date()).format('YYYY-MM-DD'), + periodeEndDate: moment(new Date()).format('YYYY-MM-DD'), + is_posted: "" + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_x_search(state, val) { + state.x_search = val + state.current_page = 1 + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_jurnalumums(state, val) { + state.jurnalumums = val + }, + update_total_jurnalumum(state, val) { + state.total_jurnalumum = val + }, + update_selected_jurnalumum(state, val) { + state.selected_jurnalumum = val + }, + update_start_date(state, val) { + state.start_date = val + }, + update_end_date(state, val) { + state.end_date = val + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val + }, + update_msg_info(state, val) { + state.msg_info = val + }, + update_drop_tipe_jurnal(state, val) { + state.drop_tipe_jurnal = val + }, + update_x_drop_tipe_jurnal(state, val) { + state.x_drop_tipe_jurnal = val + }, + update_open_print(state, value) { + state.open_print = value + }, + + // state jurnal umum + update_user(state, val) { + state.user = val + }, + update_dialog_is_active(state, val) { + state.dialog_is_active = val + }, + update_loading_jurnaltype(state, val) { + state.loading_jurnaltype = val + }, + update_jurnaltypes(state, val) { + state.jurnaltypes = val + }, + update_selected_jurnaltype(state, val) { + state.selected_jurnaltype = val + }, + update_selected_jurnaltype_u(state, val) { + state.selected_jurnaltype_u = val + }, + update_xdate(state, val) { + state.xdate = val + }, + update_periodes(state, val) { + state.periodes = val + }, + update_selected_periode(state, val) { + state.selected_periode = val + }, + update_autocomplete_status(state, val) { + state.update_autocomplete_status = val + }, + update_dialogdetail(state, val) { + state.dialogdetail = val + }, + update_coalist(state, val) { + state.coalist = val + }, + update_selected_coa(state, val) { + state.selected_coa = val + }, + update_errors(state, val) { + state.errors = val + }, + update_errors_save_jurnal(state, val) { + state.errors_save_jurnal = val + }, + update_xsummary(state, val) { + state.xsummary = val + }, + update_open_dialog_detail_info(state, val) { + state.open_dialog_detail_info = val + }, + update_msg_detail_info(state, val) { + state.msg_detail_info = val + }, + update_msg_detail_info(state, val) { + state.msg_detail_info = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_act(state, val) { + state.act = val + }, + update_title(state, val) { + state.title = val + }, + update_deskripsi(state, val) { + state.deskripsi = val + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val + }, + update_selected_jurnaldetail(state, val) { + state.selected_jurnaldetail = val + }, + update_periodeStartDate(state, val) { + state.periodeStartDate = val + }, + update_periodeEndDate(state, val) { + state.periodeEndDate = val + }, + update_is_posted(state, val) { + state.is_posted = val + }, + update_dialogjurnaltype(state, val) { + state.dialogjurnaltype = val + } + }, + actions: { + async search(context, prm) { + context.commit("update_search_status", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + context.commit("update_msg_info", resp.message) + context.commit("update_open_dialog_info", true) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + context.commit("update_msg_info", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_jurnalumums", data.records) + context.commit("update_total_jurnalumum", data.total) + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + context.commit("update_msg_info", e.message) + context.commit("update_open_dialog_info", true) + } + }, + + async openjurnaltype(context) { + context.commit("update_loading_jurnaltype", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getjurnaltype(prm) + if (resp.status != "OK") { + context.commit("update_loading_jurnaltype", false) + } else { + context.commit("update_loading_jurnaltype", false) + context.commit("update_drop_tipe_jurnal", resp.data.records) + } + } catch (e) { + context.commit("update_loading_jurnaltype", false) + } + }, + + // jurnal umum + async getjurnaltype(context) { + context.commit("update_loading_jurnaltype", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getjurnaltype(prm) + if (resp.status != "OK") { + context.commit("update_loading_jurnaltype", false) + } else { + context.commit("update_loading_jurnaltype", false) + context.commit("update_jurnaltypes", resp.data.records) + context.commit("update_selected_jurnaltype", resp.data.defaultju) + context.commit("update_selected_jurnaltype_u", resp.data.defaultju) + } + } catch (e) { + context.commit("update_loading_jurnaltype", false) + } + }, + + async getperiode(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.getperiode(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_autocomplete_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records + } + + context.commit("update_periodes", data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + + async searchcoa(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.searchcoa(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_autocomplete_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records + } + + context.commit("update_coalist", data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + + async savejurnalumum(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.savejurnalumum(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + var msg = " Journal " + prm.title + " berhasil di ditambahkan" + context.commit("update_msg_success", msg) + context.dispatch("search", { + regionalid: context.state.user.S_RegionalID, + branchid: context.state.user.M_BranchID, + current_page: context.state.current_page, + search: context.state.x_search, + startdate: context.state.start_date, + enddate: context.state.end_date, + last_id: -1 + }) + } else { + context.commit("update_errors_save_jurnal", []) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + + async editjurnalumum(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.editjurnalumum(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + var msg = " Journal " + prm.title + " berhasil di diupdate" + context.commit("update_msg_success", msg) + context.dispatch("search", { + regionalid: context.state.user.S_RegionalID, + branchid: context.state.user.M_BranchID, + current_page: context.state.current_page, + search: context.state.x_search, + startdate: context.state.start_date, + enddate: context.state.end_date, + last_id: -1 + }) + } else { + context.commit("update_errors_save_jurnal", []) + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + + async deletejurnalumum(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deletejurnalumum(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + var msg = " Journal " + prm.title + " berhasil dihapus" + context.commit("update_msg_success", msg) + context.dispatch("search", { + regionalid: context.state.user.S_RegionalID, + branchid: context.state.user.M_BranchID, + current_page: context.state.current_page, + search: context.state.x_search, + startdate: context.state.start_date, + enddate: context.state.end_date, + last_id: -1 + }) + } else { + context.commit("update_errors_save_jurnal", []) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + }, +}; diff --git a/test/vuex/acc-one-jurnal/modules/pengeluaranbarang.js b/test/vuex/acc-one-jurnal/modules/pengeluaranbarang.js new file mode 100644 index 0000000..1a7569e --- /dev/null +++ b/test/vuex/acc-one-jurnal/modules/pengeluaranbarang.js @@ -0,0 +1,404 @@ +import * as api from "../api/pengeluaranbarang.js"; + +export default { + namespaced: true, + state: { + search_status: 0, + insert_status: 0, + insert_error: '', + current_page: 1, + + user: one_user(), + keluar_barang_dialog: false, + selected_jurnal_type: {}, + periode_start_date: moment(new Date()).format('YYYY-MM-DD'), + periode_end_date: moment(new Date()).format('YYYY-MM-DD'), + + input_company: one_user().M_BranchCompanyName, + input_regional: one_user().S_RegionalName, + input_cabang: one_user().M_BranchName, + input_date: moment(new Date()).format('YYYY-MM-DD'), + input_title: "", + input_description: "", + list_periode: [], + selected_periode: {}, + + + detail_dialog: false, + table_detail: [], + list_coa: [], + selected_coa: {}, + input_detail_debet: 0, + input_detail_kredit: 0, + summary_detail: { + total_debet: 0, + total_kredit: 0, + total_balance: 0 + }, + + opp_type: "add", + crud_jurnal_status: 0, + crud_jurnal: { + state: false, + msg: "", + color: "error" + }, + + current_jurnal: {} + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_insert_status(state, val) { + state.insert_status = val + }, + update_insert_error(state, val) { + state.insert_error = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_user(state, val) { + state.user = val + }, + update_pengeluaran_barang_dialog(state, val) { + state.keluar_barang_dialog = val + }, + update_selected_jurnal_type(state, val) { + state.selected_jurnal_type = val + }, + update_periode_start_date(state, val) { + state.periode_start_date = val + }, + update_periode_end_date(state, val) { + state.periode_end_date = val + }, + update_input_company(state, val) { + state.input_company = val + }, + update_input_regional(state, val) { + state.input_regional = val + }, + update_input_cabang(state, val) { + state.input_cabang = val + }, + update_input_date(state, val) { + state.input_date = val + }, + update_input_title(state, val) { + state.input_title = val + }, + update_input_description(state, val) { + state.input_description = val + }, + update_list_periode(state, val) { + state.list_periode = val + }, + update_selected_periode(state, val) { + state.selected_periode = val + }, + update_list_coa(state, val) { + state.list_coa = val + }, + update_selected_coa(state, val) { + state.selected_coa = val + }, + update_detail_dialog(state, val) { + state.detail_dialog = val + }, + update_table_detail(state, val) { + state.table_detail = val + }, + update_summary_detail(state, val) { + state.summary_detail = val + }, + update_input_detail_debet(state, val) { + state.input_detail_debet = val + }, + update_input_detail_kredit(state, val) { + state.input_detail_kredit = val + }, + update_crud_jurnal_status(state, val) { + state.crud_jurnal_status = val + }, + update_crud_jurnal(state, val) { + state.crud_jurnal = val + }, + update_opp_type(state, val) { + state.opp_type = val + }, + update_current_jurnal(state, val) { + state.current_jurnal = val + } + }, + actions: { + async getperiode(context, params) { + context.commit("update_search_status", 1) + try { + params.token = one_token() + let resp = await api.get_periode(params) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + } else { + context.commit("update_list_periode", resp.data.records) + context.commit("update_search_status", 2) + } + } catch (error) { + context.commit("update_search_status", 3) + } + }, + async getcoa(context, params) { + context.commit("update_search_status", 1) + try { + params.token = one_token() + let resp = await api.get_coa(params) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + } else { + context.commit("update_list_coa", resp.data.records) + context.commit("update_search_status", 2) + } + } catch (error) { + context.commit("update_search_status", 3) + } + }, + async add_detail_table(context, params) { + context.commit("update_insert_status", 1) + try { + let curr_detail = context.state.table_detail + curr_detail.push(params) + + let k = 0 + let d = 0 + curr_detail.forEach(item => { + d += parseFloat(Number(item.debet).toFixed(2)) + k += parseFloat(Number(item.kredit).toFixed(2)) + }); + + let summary = { + total_kredit: k, + total_debet: d, + total_balance: (d - k) + } + + + context.commit("update_table_detail", curr_detail) + context.commit("update_summary_detail", summary) + context.commit("update_insert_status", 2) + } catch (error) { + context.commit("update_insert_error", "error insert detail jurnal") + context.commit("update_insert_status", 3) + } + }, + async del_detail_table(context, params) { + context.commit("update_insert_status", 1) + try { + let curr_detail = context.state.table_detail + if (params > -1) { + curr_detail.splice(params, 1) + } + + let k = 0 + let d = 0 + if (Object.keys(curr_detail).length > 0) { + curr_detail.forEach(item => { + d += parseFloat(Number(item.debet).toFixed(2)) + k += parseFloat(Number(item.kredit).toFixed(2)) + }) + } + + let summary = { + total_kredit: k, + total_debet: d, + total_balance: (d - k) + } + + context.commit("update_table_detail", curr_detail) + context.commit("update_summary_detail", summary) + context.commit("update_insert_status", 2) + } catch (error) { + context.commit("update_insert_error", "error delete detail jurnal") + context.commit("update_insert_status", 3) + } + }, + async simpan_jurnal(context, params) { + context.commit("update_crud_jurnal_status", 1) + try { + params.token = one_token() + let resp = await api.simpanjurnal(params) + if (resp.status != "OK") { + let a = { + state: true, + msg: resp.message, + color: "error" + } + context.commit("update_crud_jurnal", a) + context.commit("update_crud_jurnal_status", 3) + } else { + let a = { + state: true, + msg: "Sukses", + color: "success" + } + context.commit("update_crud_jurnal", a) + context.commit("update_crud_jurnal_status", 2) + context.commit("update_pengeluaran_barang_dialog", false) + + context.dispatch('jurnalumum/search', { + current_page: context.rootState.jurnalumum.current_page, + search: context.rootState.jurnalumum.x_search, + startdate: context.rootState.jurnalumum.start_date, + enddate: context.rootState.jurnalumum.end_date, + regionalid: context.rootState.jurnalumum.user.S_RegionalID, + branchid: context.rootState.jurnalumum.user.M_BranchID, + last_id: -1 + }, { root: true }) + } + } catch (error) { + let a = { + state: true, + msg: error.message, + color: "error" + } + context.commit("update_crud_jurnal", a) + context.commit("update_crud_jurnal_status", 3) + } + }, + async load_jurnal(context, params) { + try { + params.token = one_token() + let resp = await api.getdetailjurnal(params) + if (resp.status != "OK") { + + } else { + let sel_jurnal = { + JurnalTypeID: resp.data.jurnal.JurnalTypeID, + JurnalTypeCode: resp.data.jurnal.JurnalTypeCode, + JurnalTypeName: resp.data.jurnal.JurnalTypeName, + JurnalTypeAccesRight: resp.data.jurnal.JurnalTypeAccesRight, + JurnalTypeIsActive: resp.data.jurnal.JurnalTypeIsActive + } + context.commit("update_selected_jurnal_type", sel_jurnal) + + let sel_periode = resp.data.periode + context.commit("update_selected_periode", sel_periode) + + let in_title = resp.data.jurnal.jurnalTitle + context.commit("update_input_title", in_title) + let in_desc = resp.data.jurnal.jurnalDescription + context.commit("update_input_description", in_desc) + let in_date = resp.data.jurnal.jurnalDate + context.commit("update_input_date", in_date) + + let j_detail = resp.data.jurnaldetail + context.commit("update_table_detail", j_detail) + + let k = 0 + let d = 0 + j_detail.forEach(item => { + d += parseFloat(Number(item.debet).toFixed(2)) + k += parseFloat(Number(item.kredit).toFixed(2)) + }) + + let summary = { + total_kredit: k, + total_debet: d, + total_balance: (d - k) + } + context.commit("update_summary_detail", summary) + context.commit("update_current_jurnal", resp.data.jurnal) + } + } catch (error) { + let a = { + state: true, + msg: error.message, + color: "error" + } + context.commit("update_crud_jurnal", a) + context.commit("update_crud_jurnal_status", 3) + } + }, + async edit_jurnal(context, params) { + try { + context.commit("update_opp_type", "edit") + context.dispatch("load_jurnal", params) + context.commit("update_pengeluaran_barang_dialog", true) + } catch (error) { + console.log(error) + } + }, + async simpan_edit_jurnal(context, params) { + context.commit("update_crud_jurnal_status", 1) + try { + params.token = one_token() + let resp = await api.editdetailjurnal(params) + if (resp.status != "OK") { + let a = { + state: true, + msg: resp.message, + color: "error" + } + context.commit("update_crud_jurnal", a) + context.commit("update_crud_jurnal_status", 3) + } else { + let a = { + state: true, + msg: "Sukses", + color: "success" + } + context.commit("update_crud_jurnal", a) + context.commit("update_crud_jurnal_status", 2) + context.commit("update_pengeluaran_barang_dialog", false) + + context.dispatch('jurnalumum/search', { + current_page: context.rootState.jurnalumum.current_page, + search: context.rootState.jurnalumum.x_search, + startdate: context.rootState.jurnalumum.start_date, + enddate: context.rootState.jurnalumum.end_date, + regionalid: context.rootState.jurnalumum.user.S_RegionalID, + branchid: context.rootState.jurnalumum.user.M_BranchID, + last_id: -1 + }, { root: true }) + } + } catch (error) { + let a = { + state: true, + msg: error.message, + color: "error" + } + context.commit("update_crud_jurnal", a) + context.commit("update_crud_jurnal_status", 3) + } + }, + async add_jurnal(context) { + try { + context.commit("update_opp_type", "add") + + context.commit("update_input_company", context.state.user.M_BranchCompanyName) + context.commit("update_input_regional", context.state.user.S_RegionalName) + context.commit("update_input_cabang", context.state.user.M_BranchName) + context.commit("update_selected_jurnal_type", context.rootState.jurnalumum.x_drop_tipe_jurnal) + + context.commit("update_selected_periode", {}) + context.commit("update_input_date", moment(new Date()).format('YYYY-MM-DD')) + context.commit("update_input_title", "") + context.commit("update_input_description", "") + + context.commit("update_table_detail", []) + context.commit("update_selected_coa", {}) + context.commit("update_input_detail_debet", 0) + context.commit("update_input_detail_kredit", 0) + let summary = { + total_kredit: 0, + total_debet: 0, + total_balance: 0 + } + context.commit("update_summary_detail", summary) + context.commit("update_pengeluaran_barang_dialog", true) + } catch (error) { + console.log(error) + } + } + } +}; \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/modules/terimaBarang.js b/test/vuex/acc-one-jurnal/modules/terimaBarang.js new file mode 100644 index 0000000..8c51a01 --- /dev/null +++ b/test/vuex/acc-one-jurnal/modules/terimaBarang.js @@ -0,0 +1,382 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/terimaBarang.js" + +export default { + namespaced: true, + state: { + user: one_user(), + dialogJurnalTerimaBarang: false, + selectedJurnalType: {}, + jurnalTypeList: [], + defaultJurnalType: {}, + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + searchPeriode: '', + selectedPeriode: {}, + periodeList: [], + loadingAutocomplete: false, + searchSupplier: '', + supplierList: [], + selectedSupplier: {}, + jurnalTitle: '', + grniValue: '', + invoiceValue: '', + jurnalDescription: '', + searchCoa: '', + selectedCoa: {}, + coaList: [], + kreditValue: 0, + debitValue: 0, + errorsAddDetail: [], + errorsAddJurnal: [], + detailsJurnalTerimaBarang: [], + detailSum: { debit: 0, credit: 0, balance: 0 }, + loadingSave: false, + dialogForm: false, + snackbar: { + state: false, + color: 'success', + msg: '' + }, + act: "", + // Untuk Edit Dialog + companyInfo: {}, + isPosted: false, + selectedJurnal: {}, + + last_id: -1, + loading: false, + startDate: moment(new Date()).format('YYYY-MM-DD'), + endDate: moment(new Date()).format('YYYY-MM-DD'), + loading: false, + sallary: 0, + description: '', + branchPercentList: [], + selectedBranchPercent: {}, + }, + mutations: { + update_dialogJurnalTerimaBarang(state, val) { + state.dialogJurnalTerimaBarang = val + }, + update_selectedJurnalType(state, val) { + state.selectedJurnalType = val + }, + update_jurnalTypeList(state, val) { + state.jurnalTypeList = val + }, + update_defaultJurnalType(state, val) { + state.defaultJurnalType = val + }, + update_selectedDate(state, val) { + state.selectedDate = val + }, + update_searchPeriode(state, val) { + state.searchPeriode = val + }, + update_selectedPeriode(state, val) { + state.selectedPeriode = val + }, + update_periodeList(state, val) { + state.periodeList = val + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val + }, + update_searchSupplier(state, val) { + state.searchSupplier = val + }, + update_selectedSupplier(state, val) { + state.selectedSupplier = val + }, + update_supplierList(state, val) { + state.supplierList = val + }, + update_jurnalTitle(state, val) { + state.jurnalTitle = val + }, + update_grniValue(state, val) { + state.grniValue = val + }, + update_invoiceValue(state, val) { + state.invoiceValue = val + }, + update_debitValue(state, val) { + state.debitValue = val + }, + update_jurnalDescription(state, val) { + state.jurnalDescription = val + }, + update_kreditValue(state, val) { + state.kreditValue = val + }, + update_coaList(state, val) { + state.coaList = val + }, + update_searchCoa(state, val) { + state.searchCoa = val + }, + update_selectedCoa(state, val) { + state.selectedCoa = val + }, + update_errorsAddDetail(state, val) { + state.errorsAddDetail = val + }, + update_errorsAddJurnal(state, val) { + state.errorsAddJurnal = val + }, + update_detailsJurnalTerimaBarang(state, val) { + state.detailsJurnalTerimaBarang = val + }, + update_detailSum(state, val) { + state.detailSum = val + }, + update_loadingSave(state, val) { + state.loadingSave = val + }, + update_snackbar(state, val) { + state.snackbar = val + }, + update_actForm(state, val) { + state.act = val + }, + update_companyInfo(state, val) { + state.companyInfo = val + }, + update_isPosted(state, val) { + state.isPosted = val + }, + update_selectedJurnal(state, val) { + state.selectedJurnal = val + }, + + + /* NOT USED YET */ + update_defaultBranch(state, val) { + state.defaultBranch = val + }, + update_branchPercentList(state, val) { + state.branchPercentList = val + }, + update_selectedBranchPercent(state, val) { + state.selectedBranchPercent = val + }, + update_loading(state, val) { + state.loading = val + }, + update_dialogForm(state, val) { + state.dialogForm = val + }, + update_startDate(state, val) { + state.startDate = val + }, + update_endDate(state, val) { + state.endDate = val + }, + update_sallary(state, val) { + state.sallary = val + }, + + }, + actions: { + async getJurnalType(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getJurnalType(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + } else { + context.commit("update_loadingAutocomplete", false) + context.commit("update_jurnalTypeList", resp.data.records) + context.commit("update_selectedJurnalType", resp.data.default) + context.commit("update_defaultJurnalType", resp.data.default) + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + + async getPeriode(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchPeriode; + prm.token = one_token() + let resp = await api.searchPeriode(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + } else { + context.commit("update_loadingAutocomplete", false) + context.commit("update_periodeList", resp.data) + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + + async getSupplier(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchSupplier; + prm.token = one_token() + let resp = await api.searchSupplier(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + } else { + context.commit("update_loadingAutocomplete", false) + context.commit("update_supplierList", resp.data) + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + + async getCoa(context) { + context.commit("update_loadingAutocomplete", true) + try { + let prm = {}; + prm.search = context.state.searchCoa; + prm.token = one_token() + let resp = await api.searchCoa(prm) + if (resp.status != "OK") { + context.commit("update_loadingAutocomplete", false) + } else { + context.commit("update_loadingAutocomplete", false) + context.commit("update_coaList", resp.data.records) + } + } catch (e) { + context.commit("update_loadingAutocomplete", false) + console.log(e) + } + }, + + async saveJurnal(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.saveJurnal(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + context.commit("jurnalumum/update_save_error_message", resp.message, { root: true }) + context.commit("jurnalumum/update_alert_error", true, { root: true }) + console.log(resp); + } else { + context.commit("jurnalumum/update_alert_success", true, { root: true }) + var msg = " Journal " + prm.jurnalTitle + " berhasil disimpan" + context.commit("jurnalumum/update_msg_success", msg, { root: true }) + + context.dispatch('jurnalumum/search', { + current_page: context.rootState.jurnalumum.current_page, + search: context.rootState.jurnalumum.x_search, + startdate: context.rootState.jurnalumum.start_date, + enddate: context.rootState.jurnalumum.end_date, + regionalid: context.rootState.jurnalumum.user.S_RegionalID, + branchid: context.rootState.jurnalumum.user.M_BranchID, + last_id: -1 + }, { root: true }) + + context.commit("update_dialogForm", false) + } + } catch (e) { + context.commit("update_loadingSave", false) + console.log(e) + } + }, + + async loadEditDialog(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.loadEditDialog(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + let snackbar = { + state: true, + color: 'error', + msg: resp.message + } + context.commit("update_snackbar", snackbar) + console.log(resp) + } else { + context.commit("update_loadingSave", false) + + context.commit("update_selectedJurnal", resp.data.jurnalHead) + context.commit("update_selectedJurnalType", { + JurnalTypeID: resp.data.jurnalHead.JurnalTypeID, + JurnalTypeName: resp.data.jurnalHead.JurnalTypeName + }) + context.commit("update_selectedDate", resp.data.jurnalHead.jurnalDate) + context.commit("update_jurnalTitle", resp.data.jurnalHead.jurnalTitle) + context.commit("update_jurnalDescription", resp.data.jurnalHead.jurnalDescription) + context.commit("update_grniValue", resp.data.jurnalHead.GRNIGR ? resp.data.jurnalHead.GRNIGR : '') + context.commit("update_invoiceValue", resp.data.jurnalHead.INVGR ? resp.data.jurnalHead.INVGR : '') + context.commit("update_isPosted", resp.data.jurnalHead.jurnalIsPosted) + + context.commit("update_selectedSupplier", resp.data.supplier) + context.commit("update_selectedPeriode", resp.data.periode) + context.commit("update_detailsJurnalTerimaBarang", resp.data.details) + + // Hitung sum + let totalDebit = 0, totalCredit = 0 + resp.data.details.forEach((item) => { + totalDebit += parseFloat(item.jurnalTxDebit) + totalCredit += parseFloat(item.jurnalTxCredit) + }) + let totalBalance = totalDebit - totalCredit + context.commit("update_detailSum", { + debit: totalDebit, + credit: totalCredit, + balance: totalBalance + }) + + context.commit("update_dialogJurnalTerimaBarang", true) + context.commit("update_actForm", 'edit') + console.log(resp.data); + } + } catch (e) { + context.commit("update_loadingSave", false) + console.log(e) + } + }, + + async updateJurnal(context, prm) { + context.commit("update_loadingSave", true) + try { + prm.token = one_token() + let resp = await api.updateJurnal(prm) + if (resp.status != "OK") { + context.commit("update_loadingSave", false) + context.commit("jurnalumum/update_save_error_message", resp.message, { root: true }) + context.commit("jurnalumum/update_alert_error", true, { root: true }) + console.log(resp) + } else { + context.commit("update_loadingSave", false) + context.commit("jurnalumum/update_alert_success", true, { root: true }) + var msg = " Journal " + prm.jurnalTitle + " berhasil diupdate" + context.commit("jurnalumum/update_msg_success", msg, { root: true }) + context.dispatch('jurnalumum/search', { + current_page: context.rootState.jurnalumum.current_page, + search: context.rootState.jurnalumum.x_search, + startdate: context.rootState.jurnalumum.start_date, + enddate: context.rootState.jurnalumum.end_date, + regionalid: context.rootState.jurnalumum.user.S_RegionalID, + branchid: context.rootState.jurnalumum.user.M_BranchID, + last_id: -1 + }, { root: true }) + console.log(resp) + } + } catch (e) { + context.commit("update_loadingSave", false) + console.log(e) + } + }, + + + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-jurnal/store.js b/test/vuex/acc-one-jurnal/store.js new file mode 100644 index 0000000..3bf8c4e --- /dev/null +++ b/test/vuex/acc-one-jurnal/store.js @@ -0,0 +1,22 @@ +import jurnalumum from "./modules/jurnalumum.js"; +import terimaBarang from "./modules/terimaBarang.js"; +import system from "../../../apps/modules/system/system.js"; +import jurnalgaji from "./modules/jurnalgaji.js"; +import pengeluaranbarang from "./modules/pengeluaranbarang.js"; +import jpbreg from "./modules/jpbreg.js"; +import jurnalbiaya from "./modules/jurnalbiaya.js"; + +export const store = new Vuex.Store({ + modules: { + jurnalumum: jurnalumum, + jurnalgaji: jurnalgaji, + terimaBarang: terimaBarang, + pengeluaranbarang: pengeluaranbarang, + jpbreg: jpbreg, + jurnalbiaya: jurnalbiaya, + system: system + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-listing-pr/api/api.js b/test/vuex/acc-one-listing-pr/api/api.js new file mode 100644 index 0000000..47dfa1e --- /dev/null +++ b/test/vuex/acc-one-listing-pr/api/api.js @@ -0,0 +1,115 @@ +const URL = "/one-api/mockup/purchase/listing/PurchaseRequestListing/"; + +export async function listing_regional(params) { + try { + var resp = await axios.post(URL + 'listing_regional', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function listing_branch(params) { + try { + var resp = await axios.post(URL + 'listing_branch', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +// export async function listing_purchase_req(params) { +// try { +// var resp = await axios.post(URL + 'listing_pr', params) +// if (resp.status != 200) { +// return { +// status: "ERR", +// message: resp.message +// } +// } +// let data = resp.data +// return data +// } catch (error) { +// return { +// status: "ERR", +// message: error.message +// } +// } +// } + +export async function listing_purchase_req(params) { + try { + var resp = await axios.post(URL + 'list_purchaserequest', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function add_flag_status(params) { + try { + var resp = await axios.post(URL + 'insertstatus', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function edit_flag_status(params) { + try { + var resp = await axios.post(URL + 'changestatus', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-listing-pr/components/filter-pr.vue b/test/vuex/acc-one-listing-pr/components/filter-pr.vue new file mode 100644 index 0000000..1aa3edc --- /dev/null +++ b/test/vuex/acc-one-listing-pr/components/filter-pr.vue @@ -0,0 +1,169 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-listing-pr/components/listing-pr.vue b/test/vuex/acc-one-listing-pr/components/listing-pr.vue new file mode 100644 index 0000000..758eb45 --- /dev/null +++ b/test/vuex/acc-one-listing-pr/components/listing-pr.vue @@ -0,0 +1,271 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-listing-pr/index.php b/test/vuex/acc-one-listing-pr/index.php new file mode 100644 index 0000000..165e0dd --- /dev/null +++ b/test/vuex/acc-one-listing-pr/index.php @@ -0,0 +1,58 @@ + + + + + + + + + + List PR + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-listing-pr/modules/listingpr.js b/test/vuex/acc-one-listing-pr/modules/listingpr.js new file mode 100644 index 0000000..f4b2cdc --- /dev/null +++ b/test/vuex/acc-one-listing-pr/modules/listingpr.js @@ -0,0 +1,197 @@ +import * as api from "../api/api.js" + +export default { + namespaced: true, + state: { + user: one_user(), + api_status: 1, + detaildialog: false, + err_msg: "", + err_val: 0, + + regional: [], + selected_regional: { + S_RegionalID: one_user()['S_RegionalID'], + S_RegionalName: one_user()['S_RegionalName'] + }, + branch: [], + selected_branch: {}, + selected_status: "SEMUA", + + startdate: new Date().toISOString().substr(0, 10), + enddate: new Date().toISOString().substr(0, 10), + list_pr: {}, + pagination: 1 + }, + mutations: { + update_err_msg(state, data) { + state.err_msg = data + }, + update_err_val(state, data) { + state.err_val = data + }, + update_startdate(state, data) { + state.startdate = data + }, + update_enddate(state, data) { + state.enddate = data + }, + update_regional(state, data) { + state.regional = data + }, + update_selected_regional(state, data) { + state.selected_regional = data + }, + update_branch(state, data) { + state.branch = data + }, + update_selected_branch(state, data) { + state.selected_branch = data + }, + update_selected_status(state, data) { + state.selected_status = data + }, + update_list_pr(state, data) { + state.list_pr = data + }, + update_pagination(state, data) { + state.pagination = data + }, + update_api_status(state, data) { + state.api_status = data + }, + update_detaildialog(state, data) { + state.detaildialog = data + } + }, + actions: { + async getregional(context, params) { + context.commit("update_err_val", 0) + try { + params.token = one_token() + let response = await api.listing_regional(params) + if (response.status != "OK") { + context.commit("update_err_val", 1) + } else { + let data = response.data.records + context.commit("update_regional", data) + } + } catch (error) { + context.commit("update_err_val", 1) + } + }, + async getbranch(context, params) { + context.commit("update_err_val", 0) + try { + params.token = one_token() + let response = await api.listing_branch(params) + if (response.status != "OK") { + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error get listing branch: ", response.message) + } else { + let data = [ + { + M_BranchCode: "ALL", + M_BranchName: "SEMUA" + }, + ...response.data.result + ] + + context.commit("update_branch", data) + } + } catch (error) { + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error get listing branch: ", error.message) + } + }, + async getlistingpurchase(context, params) { + context.commit("update_err_val", 0) + try { + params.token = one_token() + let resp = await api.listing_purchase_req(params) + if (resp.status != "OK") { + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error get listing branch: ", response.message) + } else { + let data = { + records: resp.data.records, + total: parseInt(resp.data.total) + } + context.commit("update_list_pr", data) + } + } catch (error) { + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error get listing request: ", error.message) + } + }, + async addflagstatus(context, params) { + context.commit("update_err_val", 0) + context.commit("update_api_status", 1) + try { + params.token = one_token() + let resp = await api.add_flag_status(params) + if (resp.status != "OK") { + context.commit("update_api_status", 3) + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error add flag request: ", resp.message) + } else { + context.dispatch("refresh_list") + context.commit("update_api_status", 2) + } + } catch (error) { + context.commit("update_api_status", 3) + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error add flag request: ", error.message) + } + }, + async editflagstatus(context, params) { + context.commit("update_api_status", 1) + context.commit("update_err_val", 0) + try { + params.token = one_token() + let resp = await api.edit_flag_status(params) + if (resp.status != "OK") { + context.commit("update_api_status", 3) + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error edit flag request: ", resp.message) + } else { + context.dispatch("refresh_list") + context.commit("update_api_status", 2) + } + } catch (error) { + context.commit("update_api_status", 3) + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error edit flag request: ", error.message) + } + }, + async refresh_list(context) { + context.commit("update_err_val", 0) + try { + let params = { + token: one_token(), + currpage: context.state.pagination, + startdate: context.state.startdate, + enddate: context.state.enddate, + regional: context.state.selected_regional.S_RegionalID, + branch: !context.state.selected_branch ? "" : context.state.selected_branch.M_BranchCode, + status: context.state.selected_status + } + let resp = await api.listing_purchase_req(params) + + if (resp.status != "OK") { + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error refresh request: ", resp.message) + } else { + let data = { + records: resp.data.records, + total: parseInt(resp.data.total) + } + context.commit("update_list_pr", data) + } + } catch (error) { + context.commit("update_err_val", 1) + context.commit("update_err_msg", "error refresh request: ", error.message) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-listing-pr/store.js b/test/vuex/acc-one-listing-pr/store.js new file mode 100644 index 0000000..c61c550 --- /dev/null +++ b/test/vuex/acc-one-listing-pr/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js"; +import listingpr from "./modules/listingpr.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + listingpr: listingpr, + }, + state: {}, + mutations: {}, + actions: {} +}) \ No newline at end of file diff --git a/test/vuex/acc-one-map-bank-coa/api/bank.js b/test/vuex/acc-one-map-bank-coa/api/bank.js new file mode 100644 index 0000000..7e624e8 --- /dev/null +++ b/test/vuex/acc-one-map-bank-coa/api/bank.js @@ -0,0 +1,162 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "bankcoa/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "bankcoa/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function search(prm) { + try { + var resp = await axios.post(URL + "bankcoa/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchCoaBank(token, prm) { + try { + var resp = await axios.post(URL + 'bankcoa/searchCoaBank', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchCoaEDC(token, prm) { + try { + var resp = await axios.post(URL + 'bankcoa/searchCoaEDC', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveupdate(prm) { + try { + var resp = await axios.post(URL + 'bankcoa/saveupdate', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deletebankcoa(prm) { + try { + var resp = await axios.post(URL + 'bankcoa/deletebankcoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function importBank(branchCode) { + try { + var resp = await axios.get(URL + `Mediajurnalauto/injectMapBankCab/${branchCode}`); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-map-bank-coa/components/bankCoaList.vue b/test/vuex/acc-one-map-bank-coa/components/bankCoaList.vue new file mode 100644 index 0000000..5a9abdf --- /dev/null +++ b/test/vuex/acc-one-map-bank-coa/components/bankCoaList.vue @@ -0,0 +1,730 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-map-bank-coa/modules/bank.js b/test/vuex/acc-one-map-bank-coa/modules/bank.js new file mode 100644 index 0000000..a23e042 --- /dev/null +++ b/test/vuex/acc-one-map-bank-coa/modules/bank.js @@ -0,0 +1,340 @@ +import * as api from "../api/bank.js" + +export default { + namespaced: true, + state: { + autocomplete_status: 0, + search_error_message: "", + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + search_status: "", + bankcoas: [], + selected_bankcoa: {}, + total_page: 0, + current_page: 1, + open_dialog_info: false, + msg_info: "", + xsearch: "", + dialog_bankCoa: false, + coa_bank_list: [], + selected_bank_coa: {}, + search_coa_bank: "", + coa_edc_list: [], + selected_edc_coa: {}, + search_coa_edc: "", + isEDC: false, + save_status: 0, + save_error_message: "", + alert_error: false, + alert_success: false, + errors_save_bankcoa: [], + msg_success: "" + }, + mutations: { + update_autocomplete_status(state, val) { + state.autocomplete_status = val + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_regionals(state, val) { + state.regionals = val + }, + update_selected_regional(state, val) { + state.selected_regional = val + }, + update_branchs(state, val) { + state.branchs = val + }, + update_selected_branch(state, val) { + state.selected_branch = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_bankcoas(state, val) { + state.bankcoas = val + }, + update_selected_bankcoa(state, val) { + state.selected_bankcoa = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val + }, + update_msg_info(state, val) { + state.msg_info = val + }, + update_xsearch(state, val) { + state.xsearch = val + }, + update_dialog_bankCoa(state, val) { + state.dialog_bankCoa = val + }, + update_coa_bank_list(state, val) { + state.coa_bank_list = val + }, + update_selected_bank_coa(state, val) { + state.selected_bank_coa = val + }, + update_search_coa_bank(state, val) { + state.search_coa_bank = val + }, + update_coa_edc_list(state, val) { + state.coa_edc_list = val + }, + update_selected_edc_coa(state, val) { + state.selected_edc_coa = val + }, + update_search_coa_edc(state, val) { + state.search_coa_edc = val + }, + update_isEDC(state, val) { + state.isEDC = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_errors_save_bankcoa(state, val) { + state.errors_save_bankcoa = val + }, + update_msg_success(state, val) { + state.msg_success = val + } + }, + actions: { + async getRegional(context) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.getRegional({ token: one_token() }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + }; + + context.commit("update_regionals", data.records); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_autocomplete_status", 3) + } + }, + async getBranch(context) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.getBranch({ token: one_token(), regionalId: context.state.selected_regional.S_RegionalID}); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + }; + + context.commit("update_branchs", data.records); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_autocomplete_status", 3) + } + }, + async search(context, prm) { + context.commit("update_search_status", 1) + try { + prm.token = one_token() + let resp = await api.search(prm); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_search_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_search_status", 2) + let data = { + records: resp.data.records, + total_page: resp.data.total_page, + }; + + context.commit("update_bankcoas", data.records); + context.commit("update_total_page", data.total_page); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_search_status", 3) + } + }, + async searchCoaBank(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.searchCoaBank(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_autocomplete_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records + } + + context.commit("update_coa_bank_list", data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async searchCoaEDC(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.searchCoaEDC(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_autocomplete_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records + } + + context.commit("update_coa_edc_list", data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async saveupdate(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.saveupdate(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_bankCoa", false) + var msg = prm.mapBankName + " berhasil di update" + context.commit("update_msg_success", msg) + context.dispatch("search", { + current_page: context.state.current_page, + search: context.state.xsearch, + branchCode: context.state.selected_branch.M_BranchCode, + regionalId: context.state.selected_regional.S_RegionalID + }) + } else { + context.commit("update_errors_save_bankcoa", []) + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + async deletebankcoa(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deletebankcoa(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + var msg = prm.mapBankName + " berhasil di hapus" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.dispatch("search", { + current_page: context.state.current_page, + search: context.state.xsearch, + branchCode: context.state.selected_branch.M_BranchCode, + regionalId: context.state.selected_regional.S_RegionalID + }) + } else { + context.commit("update_errors_save_bankcoa", []) + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + context.commit("update_save_error_message", e.message) + } + }, + async doImportBank(context, prm) { + context.commit("update_save_status", 1) + try { + let branchCode = prm.branchCode; + let resp = await api.importBank(branchCode) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + context.commit("update_alert_success", true) + var msg = resp.data.msg + var countInsert = resp.data.inserted_rows.length + var pesan = msg + ", jumlah insert : " + countInsert + context.commit("update_msg_success", pesan) + context.commit("update_alert_success", true) + context.dispatch("search", { + current_page: context.state.current_page, + search: context.state.xsearch, + branchCode: context.state.selected_branch.M_BranchCode, + regionalId: context.state.selected_regional.S_RegionalID + }) + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + context.commit("update_save_error_message", e.message) + } + }, + }, +} \ No newline at end of file diff --git a/test/vuex/acc-one-map-bank-coa/store.js b/test/vuex/acc-one-map-bank-coa/store.js new file mode 100644 index 0000000..5e20992 --- /dev/null +++ b/test/vuex/acc-one-map-bank-coa/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import bank from "./modules/bank.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + bank:bank, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-map-faclass-v2/api/faclass.js b/test/vuex/acc-one-map-faclass-v2/api/faclass.js new file mode 100644 index 0000000..44faa79 --- /dev/null +++ b/test/vuex/acc-one-map-faclass-v2/api/faclass.js @@ -0,0 +1,152 @@ +const URL = "/one-api/map/Faclassv2"; + +export async function getAcAccumDepre(prm) { + try { + var resp = await axios.post(URL + '/getAcAccumDepre', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getAcDepreCost(prm) { + try { + var resp = await axios.post(URL + '/getAcDepreCost', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getAcCoa(prm) { + try { + var resp = await axios.post(URL + '/getAcCoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search(prm) { + try { + var resp = await axios.post(URL + "/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function addData(prm) { + try { + var resp = await axios.post(URL + '/addData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getByID(prm) { + try { + var resp = await axios.post(URL + '/get_by_id', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editData(prm) { + try { + var resp = await axios.post(URL + '/editData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteData(prm) { + try { + var resp = await axios.post(URL + '/deleteData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-map-faclass-v2/components/faclass.vue b/test/vuex/acc-one-map-faclass-v2/components/faclass.vue new file mode 100644 index 0000000..4db5228 --- /dev/null +++ b/test/vuex/acc-one-map-faclass-v2/components/faclass.vue @@ -0,0 +1,945 @@ + + + + + diff --git a/test/vuex/acc-one-map-faclass-v2/index.php b/test/vuex/acc-one-map-faclass-v2/index.php new file mode 100644 index 0000000..d5d3e01 --- /dev/null +++ b/test/vuex/acc-one-map-faclass-v2/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-map-faclass-v2/modules/faclass.js b/test/vuex/acc-one-map-faclass-v2/modules/faclass.js new file mode 100644 index 0000000..d954f37 --- /dev/null +++ b/test/vuex/acc-one-map-faclass-v2/modules/faclass.js @@ -0,0 +1,640 @@ +import * as api from "../api/faclass.js" + +export default { + namespaced: true, + state: { + Fa_ClassID: 0, + a_coas: [], + a_msg_info: '', + a_open_dialog_info: false, + a_save_status: 0, + // search table + a_x_search: '', + a_current_page: 1, + a_last_id: -1, + a_total_coa: 0, + // search table + a_selected_a_coa: {}, + a_search_status: 0, + a_alert_success: false, + a_msg_success: '', + a_alert_error: false, + a_save_error_message: '', + dialog_add_coa: false, + dialog_edit_coa: false, + e_loading_nat_group: false, + // text classname + a_classname: '', + e_classname: '', + // ac coa + a_loading_coa: false, + e_loading_coa: false, + a_coa_list: [], + a_coa: {}, + a_coa_search: '', + + e_coa_list: [], + e_coa: {}, + e_coa_search: '', + // text deprecorp + a_deprecorp: '', + a_age: 0, + e_age: 0, + e_deprecorp: '', + // ac coa accum depre + a_loading_coa_accum_depre: false, + e_loading_coa_accum_depre: false, + a_coa_accum_depre_list: [], + a_coa_accum_depre: {}, + a_coa_search_accum_depre: '', + + e_coa_accum_depre_list: [], + e_coa_accum_depre: {}, + e_coa_accum_depre_search: '', + + a_loading_coa_depre_cost: false, + e_loading_coa_depre_cost: false, + a_coa_depre_cost_list: [], + a_coa_depre_cost: {}, + a_coa_search_depre_cost: '', + + e_coa_depre_cost_list: [], + e_coa_depre_cost: {}, + e_coa_depre_cost_search: '', + // text note + a_note: '', + e_note: '', + a_errors_save: [], + Fa_ClassID: 0, + a_errors_save_coa: [], + }, + mutations: { + update_a_errors_save_coa(state, val) { + state.a_errors_save_coa = val + }, + update_a_selected_a_coa(state, val) { + state.a_selected_a_coa = val + }, + update_e_loading_nat_group(state, val) { + state.e_loading_nat_group = val + }, + update_a_errors_save(state, val) { + state.a_errors_save = val + }, + update_a_save_error_message(state, val) { + state.a_save_error_message = val + }, + update_a_alert_error(state, val) { + state.a_alert_error = val + }, + update_a_msg_success(state, val) { + state.a_msg_success = val + }, + update_a_msg_info(state, val) { + state.a_msg_info = val + }, + update_a_open_dialog_info(state, val) { + state.a_open_dialog_info = val + }, + update_a_alert_success(state, val) { + state.a_alert_success = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + //table + update_a_search_error_message(state, val) { + state.a_search_error_message = val + }, + update_a_search_status(state, val) { + state.a_search_status = val + }, + update_a_x_search(state, val) { + state.a_x_search = val + }, + update_a_current_page(state, val) { + state.a_current_page = val + }, + update_a_last_id(state, val) { + state.a_last_id = val + }, + update_a_total_coa(state, val) { + state.a_total_coa = val + }, + update_a_a_coas(state, val) { + state.a_coas = val + }, + // text classname + update_a_classname(state, val) { + state.a_classname = val + }, + update_e_classname(state, val) { + state.e_classname = val + }, + // ac coa + update_a_loading_coa(state, val) { + state.a_loading_coa = val + }, + update_e_loading_coa(state, val) { + state.e_loading_coa = val + }, + update_a_coa_list(state, val) { + state.a_coa_list = val + }, + update_e_coa_list(state, val) { + state.e_coa_list = val + }, + update_a_coa(state, val) { + state.a_coa = val + }, + update_e_coa(state, val) { + state.e_coa = val + }, + update_a_coa_search(state, val) { + state.a_coa_search = val + }, + update_e_coa_search(state, val) { + state.e_coa_search = val + }, + // text depre corp + update_a_deprecorp(state, val) { + state.a_deprecorp = val + }, + update_a_age(state, val) { + state.a_age = val + }, + update_e_age(state, val) { + state.e_age = val + }, + update_e_deprecorp(state, val) { + state.e_deprecorp = val + }, + // ac coa accum depre + update_a_loading_coa_accum_depre(state, val) { + state.a_loading_coa_accum_depre = val + }, + update_e_loading_coa_accum_depre(state, val) { + state.e_loading_coa_accum_depre = val + }, + update_a_coa_accum_depre_list(state, val) { + state.a_coa_accum_depre_list = val + }, + update_e_coa_accum_depre_list(state, val) { + state.e_coa_accum_depre_list = val + }, + update_a_coa_accum_depre(state, val) { + state.a_coa_accum_depre = val + }, + update_e_coa_accum_depre(state, val) { + state.e_coa_accum_depre = val + }, + update_a_coa_search_accum_depre(state, val) { + state.a_coa_search_accum_depre = val + }, + update_e_coa_accum_depre_search(state, val) { + state.e_coa_accum_depre_search = val + }, + update_a_loading_coa_depre_cost(state, val) { + state.a_loading_coa_depre_cost = val + }, + update_e_loading_coa_depre_cost(state, val) { + state.e_loading_coa_depre_cost = val + }, + update_a_coa_depre_cost_list(state, val) { + state.a_coa_depre_cost_list = val + }, + update_e_coa_depre_cost_list(state, val) { + state.e_coa_depre_cost_list = val + }, + update_a_coa_depre_cost(state, val) { + state.a_coa_depre_cost = val + }, + update_e_coa_depre_cost(state, val) { + state.e_coa_depre_cost = val + }, + update_a_coa_search_depre_cost(state, val) { + state.a_coa_search_depre_cost = val + }, + update_e_coa_depre_cost_search(state, val) { + state.e_coa_depre_cost_search = val + }, + // text note + update_a_note(state, val) { + state.a_note = val + }, + update_e_note(state, val) { + state.e_note = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + update_dialog_edit_coa(state, val) { + state.dialog_edit_coa = val + }, + update_Fa_ClassID(state, val) { + state.Fa_ClassID = val + }, + update_a_save_status(state, val) { + state.a_save_status = val + }, + }, + actions: { + // search + async search(context, prm) { + context.commit("update_a_search_status", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", resp.message) + context.commit("update_a_msg_info", resp.message) + context.commit("update_a_open_dialog_info", true) + } else { + context.commit("update_a_search_status", 2) + context.commit("update_a_search_error_message", "") + context.commit("update_a_msg_info", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_a_a_coas", data.records) + context.commit("update_a_total_coa", data.total) + } + } catch (e) { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", e.message) + context.commit("update_a_msg_info", e.message) + context.commit("update_a_open_dialog_info", true) + } + }, + + // get ac coa from api + async open_add_coa(context, payload) { + context.commit("update_a_loading_coa", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcCoa(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa", false) + context.commit("update_a_coa_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa", false) + } + }, + + // get ac coa accum depre from api + async open_add_coa_accum_depre(context, payload) { + context.commit("update_a_loading_coa_accum_depre", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcAccumDepre(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_accum_depre", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_accum_depre", false) + context.commit("update_a_coa_accum_depre_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_accum_depre", false) + } + }, + + async open_add_coa_depre_cost(context, payload) { + context.commit("update_a_loading_coa_depre_cost", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcDepreCost(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_depre_cost", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_depre_cost", false) + context.commit("update_a_coa_depre_cost_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_depre_cost", false) + } + }, + // add data + async add_data(context, payload) { + context.commit("update_a_save_status", 1) + try { + let prm = {}; + prm.token = one_token() + prm.a_classname = payload.a_classname_param + prm.a_coa = payload.a_coa_param + prm.a_deprecorp = payload.a_deprecorp_param + prm.a_age = payload.a_age_param + prm.a_coa_accum_depre = payload.a_coa_accum_depre_param + prm.a_coa_depre_cost = payload.a_coa_depre_cost_param + prm.a_note = payload.a_note_param + + let resp = await api.addData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Add Data Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_add_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + + context.commit("faclass/update_dialog_add_coa", false); + context.commit("faclass/update_a_classname", ""); + context.commit("faclass/update_a_coa", {}); + context.commit("faclass/update_a_deprecorp", ""); + context.commit("faclass/update_a_age", 0); + context.commit("faclass/update_a_coa_accum_depre", {}); + context.commit("faclass/update_a_coa_depre_cost", {}); + context.commit("faclass/update_a_note", ""); + } else { + context.commit("update_a_errors_save", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + + // get_by_id + async get_by_id(context, payload) { + context.commit("update_e_loading_nat_group", true) + try { + let prm = {}; + prm.token = one_token() + // fa_class + prm.Fa_ClassID = payload.Fa_ClassID + // coa + prm.Fa_ClassCoaID = payload.Fa_ClassCoaID + // accum depre + prm.Fa_ClassAccumDepreCoaID = payload.Fa_ClassAccumDepreCoaID + + prm.Fa_ClassAccumDepreCostCoaID = payload.DepreCostCoaID + + let resp = await api.getByID(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_nat_group", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_nat_group", true) + + // MapNatGroup_ID + context.commit("update_Fa_ClassID", resp.data.record_fa_class[0].Fa_ClassID) + + // coa + context.commit("update_e_coa_list", resp.data.records_coa) + context.commit("update_e_coa", { + coaID: resp.data.records_coa[0].coaID, + coaAccountNo: resp.data.records_coa[0].coaAccountNo, + coaDescription: resp.data.records_coa[0].coaDescription, + coaSubDescription: resp.data.records_coa[0].coaSubDescription, + coaAccountType: resp.data.records_coa[0].coaAccountType, + coaSpecialAccountType: resp.data.records_coa[0].coaSpecialAccountType, + coaIsInput: resp.data.records_coa[0].coaIsInput, + coaReportSchedule: resp.data.records_coa[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_coa[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_coa[0].coaCashFlowCategory, + coaCreated: resp.data.records_coa[0].coaCreated, + coaLastUpdated: resp.data.records_coa[0].coaLastUpdated, + coaIsActive: resp.data.records_coa[0].coaIsActive, + coaLevel: resp.data.records_coa[0].coaLevel + }) + + // accum depre + context.commit("update_e_coa_accum_depre_list", resp.data.records_accum_depre) + context.commit("update_e_coa_accum_depre", { + coaID: resp.data.records_accum_depre[0].coaID, + coaAccountNo: resp.data.records_accum_depre[0].coaAccountNo, + coaDescription: resp.data.records_accum_depre[0].coaDescription, + coaSubDescription: resp.data.records_accum_depre[0].coaSubDescription, + coaAccountType: resp.data.records_accum_depre[0].coaAccountType, + coaSpecialAccountType: resp.data.records_accum_depre[0].coaSpecialAccountType, + coaIsInput: resp.data.records_accum_depre[0].coaIsInput, + coaReportSchedule: resp.data.records_accum_depre[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_accum_depre[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_accum_depre[0].coaCashFlowCategory, + coaCreated: resp.data.records_accum_depre[0].coaCreated, + coaLastUpdated: resp.data.records_accum_depre[0].coaLastUpdated, + coaIsActive: resp.data.records_accum_depre[0].coaIsActive, + coaLevel: resp.data.records_accum_depre[0].coaLevel + }) + + context.commit("update_e_coa_depre_cost_list", resp.data.records_depre_cost) + context.commit("update_e_coa_depre_cost", { + coaID: resp.data.records_depre_cost[0].coaID, + coaAccountNo: resp.data.records_depre_cost[0].coaAccountNo, + coaDescription: resp.data.records_depre_cost[0].coaDescription, + coaSubDescription: resp.data.records_depre_cost[0].coaSubDescription, + coaAccountType: resp.data.records_depre_cost[0].coaAccountType, + coaSpecialAccountType: resp.data.records_depre_cost[0].coaSpecialAccountType, + coaIsInput: resp.data.records_depre_cost[0].coaIsInput, + coaReportSchedule: resp.data.records_depre_cost[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_depre_cost[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_depre_cost[0].coaCashFlowCategory, + coaCreated: resp.data.records_depre_cost[0].coaCreated, + coaLastUpdated: resp.data.records_depre_cost[0].coaLastUpdated, + coaIsActive: resp.data.records_depre_cost[0].coaIsActive, + coaLevel: resp.data.records_depre_cost[0].coaLevel + }) + // fa classname + context.commit("update_e_classname", resp.data.record_fa_class[0].Fa_ClassName) + + // note + context.commit("update_e_note", resp.data.record_fa_class[0].Fa_ClassAccumNote) + + // depre corp + context.commit("update_e_deprecorp", resp.data.record_fa_class[0].Fa_ClassDepreCorp) + + context.commit("update_e_age", resp.data.record_fa_class[0].Fa_ClassAgeAsset) + + context.commit("update_dialog_edit_coa", true) + } + } catch (e) { + context.commit("update_e_loading_nat_group", false) + } + }, + + // get ac coa from api + async open_edit_coa(context, payload) { + context.commit("update_e_loading_coa", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcCoa(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa", false) + context.commit("update_e_coa_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa", false) + } + }, + + // get ac coa accum depre from api + async open_edit_coa_accum_depre(context, payload) { + context.commit("update_e_loading_coa_accum_depre", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcAccumDepre(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa_accum_depre", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa_accum_depre", false) + context.commit("update_e_coa_accum_depre_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa_accum_depre", false) + } + }, + async open_edit_coa_depre_cost(context, payload) { + context.commit("update_e_loading_coa_depre_cost", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcAccumDepre(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa_depre_cost", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa_depre_cost", false) + context.commit("update_e_coa_depre_cost_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa_depre_cost", false) + } + }, + + // edit data + async edit_data(context, payload) { + context.commit("update_a_save_status", 1) + try { + let prm = {}; + prm.token = one_token() + prm.Fa_ClassID = payload.Fa_ClassID + prm.e_classname = payload.e_classname_param + prm.e_coa = payload.e_coa_param + prm.e_deprecorp = payload.e_deprecorp_param + prm.e_coa_accum_depre = payload.e_coa_accum_depre_param + prm.e_coa_depre_cost = payload.e_coa_depre_cost_param + prm.e_note = payload.e_note_param + prm.e_age = payload.e_age_param + + let resp = await api.editData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Edit Data Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_edit_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + + // delete data + async delete_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteData(prm) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Coa " + prm.Fa_ClassName + " berhasil dihapus" + context.commit("update_a_msg_success", msg) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + }, +} \ No newline at end of file diff --git a/test/vuex/acc-one-map-faclass-v2/store.js b/test/vuex/acc-one-map-faclass-v2/store.js new file mode 100644 index 0000000..4640a6e --- /dev/null +++ b/test/vuex/acc-one-map-faclass-v2/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import faclass from "./modules/faclass.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + faclass:faclass, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-map-natgroup/api/a_coa.js b/test/vuex/acc-one-map-natgroup/api/a_coa.js new file mode 100644 index 0000000..2af03ba --- /dev/null +++ b/test/vuex/acc-one-map-natgroup/api/a_coa.js @@ -0,0 +1,192 @@ +const URL = "/one-api/map/Natgroup"; + +export async function getNatGroup(prm) { + try { + var resp = await axios.post(URL + '/getNatGroup', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAcUangMuka(prm) { + try { + var resp = await axios.post(URL + '/getAcUangMuka', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAcHutang(prm) { + try { + var resp = await axios.post(URL + '/getAcHutang', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAcDiscPendapatan(prm) { + try { + var resp = await axios.post(URL + '/getAcDiscPendapatan', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAcReturPendapatan(prm) { + try { + var resp = await axios.post(URL + '/getAcReturPendapatan', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function addData(prm) { + try { + var resp = await axios.post(URL + '/addData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteData(prm) { + try { + var resp = await axios.post(URL + '/deleteData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search(prm) { + try { + var resp = await axios.post(URL + "/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getByID(prm) { + try { + var resp = await axios.post(URL + '/get_by_id', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editData(prm) { + try { + var resp = await axios.post(URL + '/editData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-map-natgroup/components/coaList.vue b/test/vuex/acc-one-map-natgroup/components/coaList.vue new file mode 100644 index 0000000..3136672 --- /dev/null +++ b/test/vuex/acc-one-map-natgroup/components/coaList.vue @@ -0,0 +1,1037 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-map-natgroup/modules/a_coa.js b/test/vuex/acc-one-map-natgroup/modules/a_coa.js new file mode 100644 index 0000000..e2ea1cc --- /dev/null +++ b/test/vuex/acc-one-map-natgroup/modules/a_coa.js @@ -0,0 +1,710 @@ +import * as api from "../api/a_coa.js" + +export default { + namespaced: true, + state: { + MapNatGroup_ID:0, + a_errors_save_coa: [], + a_selected_a_coa: {}, + a_coas: [], + a_save_status: 0, + a_save_error_message: '', + a_msg_success: '', + a_msg_info: '', + a_open_dialog_info: false, + a_alert_error: false, + a_alert_success: false, + a_loading_coa_list: false, + a_loading_nat_group: false, + e_loading_nat_group: false, + + a_loading_coa_uang_muka: false, + e_loading_coa_uang_muka: false, + a_loading_coa_hutang: false, + e_loading_coa_hutang: false, + a_loading_coa_disc_pendapatan: false, + e_loading_coa_disc_pendapatan: false, + a_loading_coa_retur_pendapatan: false, + dialog_add_coa: false, + dialog_edit_coa: false, + // search table + a_x_search: '', + a_current_page: 1, + a_last_id: -1, + a_total_coa: 0, + // search table + // dropdown add nat_group + a_nat_group_list: [], + a_nat_group: {}, + e_nat_group_list:[], + e_nat_group: {}, + // dropdown add nat_group + // ac add uang muka + a_coa_uang_muka_list: [], + a_coa_uang_muka: {}, + a_coa_search_uang_muka: '', + e_coa_uang_muka_list: [], + e_coa_uang_muka: {}, + // ac add uang muka + // ac add hutang + a_coa_hutang_list: [], + a_coa_hutang: {}, + a_coa_search_hutang: '', + e_coa_hutang_list: [], + e_coa_hutang: {}, + // ac add hutang + // ac add disc pendapatan + a_coa_disc_pendapatan_list: [], + a_coa_disc_pendapatan: {}, + a_coa_search_disc_pendapatan: '', + + e_coa_disc_pendapatan_list: [], + e_coa_disc_pendapatan: {}, + // ac add disc pendapatan + // ac add retur pendapatan + a_coa_retur_pendapatan_list: [], + a_coa_retur_pendapatan: {}, + a_coa_search_retur_pendapatan: '', + + e_coa_retur_pendapatan_list: [], + e_coa_retur_pendapatan: {}, + // ac add retur pendapatan + + }, + mutations: { + update_MapNatGroup_ID(state,val){ + state.MapNatGroup_ID = val + }, + update_a_errors_save_coa(state, val){ + state.a_errors_save_coa = val + }, + update_a_search_error_message(state, val) { + state.a_search_error_message = val + }, + update_a_search_status(state, val) { + state.a_search_status = val + }, + update_a_selected_a_coa(state, val) { + state.a_selected_a_coa = val + }, + update_a_a_coas(state, val) { + state.a_coas = val + }, + update_a_open_dialog_info(state, val) { + state.a_open_dialog_info = val + }, + update_a_msg_info(state, val) { + state.a_msg_info = val + }, + update_a_x_search(state, val) { + state.a_x_search = val + }, + update_a_current_page(state, val) { + state.a_current_page = val + }, + update_a_last_id(state, val) { + state.a_last_id = val + }, + update_a_total_coa(state, val) { + state.a_total_coa = val + }, + update_a_msg_success(state, val) { + state.a_msg_success = val + }, + update_a_save_status(state, val) { + state.a_save_status = val + }, + update_a_save_error_message(state, val) { + state.a_save_error_message = val + }, + update_a_alert_success(state, val) { + state.a_alert_success = val + }, + update_a_alert_error(state, val) { + state.a_alert_error = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + update_dialog_edit_coa(state, val) { + state.dialog_edit_coa = val + }, + update_a_loading_nat_group(state, val) { + state.a_loading_nat_group = val + }, + update_e_loading_nat_group(state, val) { + state.e_loading_nat_group = val + }, + update_a_nat_group(state, val) { + state.a_nat_group = val + }, + update_e_nat_group(state, val) { + state.e_nat_group = val + }, + update_a_nat_group_list(state, val) { + state.a_nat_group_list = val + }, + update_e_nat_group_list(state, val) { + state.e_nat_group_list = val + }, + // uang muka + update_a_loading_coa_uang_muka(state, val) { + state.a_loading_coa_uang_muka = val + }, + update_e_loading_coa_uang_muka(state, val) { + state.e_loading_coa_uang_muka = val + }, + update_a_coa_uang_muka(state, val) { + state.a_coa_uang_muka = val + }, + update_e_coa_uang_muka(state, val) { + state.e_coa_uang_muka = val + }, + update_a_coa_uang_muka_list(state, val) { + state.a_coa_uang_muka_list = val + }, + update_e_coa_uang_muka_list(state, val) { + state.e_coa_uang_muka_list = val + }, + update_a_coa_search_uang_muka(state, val) { + state.a_coa_search_uang_muka = val + }, + // hutang + update_a_coa_hutang(state, val) { + state.a_coa_hutang = val + }, + update_a_coa_hutang_list(state, val) { + state.a_coa_hutang_list = val + }, + update_a_coa_search_hutang(state, val) { + state.a_coa_search_hutang = val + }, + update_a_loading_coa_hutang(state, val) { + state.a_loading_coa_hutang = val + }, + + update_e_coa_hutang(state, val) { + state.e_coa_hutang = val + }, + update_e_coa_hutang_list(state, val) { + state.e_coa_hutang_list = val + }, + update_e_loading_coa_hutang(state, val) { + state.e_loading_coa_hutang = val + }, + + // disc. pendapatan + update_a_coa_disc_pendapatan(state, val) { + state.a_coa_disc_pendapatan = val + }, + update_a_coa_disc_pendapatan_list(state, val) { + state.a_coa_disc_pendapatan_list = val + }, + update_a_coa_search_disc_pendapatan(state, val) { + state.a_coa_search_disc_pendapatan = val + }, + update_a_loading_coa_disc_pendapatan(state, val) { + state.a_loading_coa_disc_pendapatan = val + }, + + update_e_coa_disc_pendapatan(state, val) { + state.e_coa_disc_pendapatan = val + }, + update_e_coa_disc_pendapatan_list(state, val) { + state.e_coa_disc_pendapatan_list = val + }, + update_e_loading_coa_disc_pendapatan(state, val) { + state.e_loading_coa_disc_pendapatan = val + }, + + // retur + update_a_coa_retur_pendapatan(state, val) { + state.a_coa_retur_pendapatan = val + }, + update_a_coa_retur_pendapatan_list(state, val) { + state.a_coa_retur_pendapatan_list = val + }, + update_a_coa_search_retur_pendapatan(state, val) { + state.a_coa_search_retur_pendapatan = val + }, + update_a_loading_coa_retur_pendapatan(state, val) { + state.a_loading_coa_retur_pendapatan = val + }, + + update_e_coa_retur_pendapatan(state, val) { + state.e_coa_retur_pendapatan = val + }, + update_e_coa_retur_pendapatan_list(state, val) { + state.e_coa_retur_pendapatan_list = val + }, + update_e_loading_coa_retur_pendapatan(state, val) { + state.e_loading_coa_retur_pendapatan = val + }, + + update_a_loading_coa_list(state, val) { + state.a_loading_coa_list = val + }, + }, + actions: { + // get nat_group from api + async open_add_nat_group(context) { + context.commit("update_a_loading_nat_group", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getNatGroup(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_nat_group", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_nat_group", false) + context.commit("update_a_nat_group_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_nat_group", false) + } + }, + // get ac uang muka from api + async open_add_coa_uang_muka(context, payload) { + context.commit("update_a_loading_coa_uang_muka", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcUangMuka(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_uang_muka", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_uang_muka", false) + context.commit("update_a_coa_uang_muka_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_uang_muka", false) + } + }, + + async open_edit_coa_uang_muka(context, payload) { + context.commit("update_e_loading_coa_uang_muka", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcUangMuka(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa_uang_muka", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa_uang_muka", false) + context.commit("update_e_coa_uang_muka_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa_uang_muka", false) + } + }, + // get ac hutang from api + async open_add_coa_hutang(context, payload) { + context.commit("update_a_loading_coa_hutang", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcHutang(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_hutang", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_hutang", false) + context.commit("update_a_coa_hutang_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_hutang", false) + } + }, + + async open_edit_coa_hutang(context, payload) { + context.commit("update_e_loading_coa_hutang", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcHutang(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa_hutang", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa_hutang", false) + context.commit("update_e_coa_hutang_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa_hutang", false) + } + }, + // get ac disc pendapatan from api + async open_add_coa_disc_pendapatan(context, payload) { + context.commit("update_a_loading_coa_disc_pendapatan", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcDiscPendapatan(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_disc_pendapatan", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_disc_pendapatan", false) + context.commit("update_a_coa_disc_pendapatan_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_disc_pendapatan", false) + } + }, + + async open_edit_coa_disc_pendapatan(context, payload) { + context.commit("update_e_loading_coa_disc_pendapatan", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcDiscPendapatan(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa_disc_pendapatan", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa_disc_pendapatan", false) + context.commit("update_e_coa_disc_pendapatan_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa_disc_pendapatan", false) + } + }, + // get ac retur pendapatan from api + async open_add_coa_retur_pendapatan(context, payload) { + context.commit("update_a_loading_coa_retur_pendapatan", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcReturPendapatan(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_retur_pendapatan", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_retur_pendapatan", false) + context.commit("update_a_coa_retur_pendapatan_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_retur_pendapatan", false) + } + }, + + async open_edit_coa_retur_pendapatan(context, payload) { + context.commit("update_e_loading_coa_retur_pendapatan", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcReturPendapatan(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa_retur_pendapatan", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa_retur_pendapatan", false) + context.commit("update_e_coa_retur_pendapatan_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa_retur_pendapatan", false) + } + }, + // search + async search(context, prm) { + context.commit("update_a_search_status", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", resp.message) + context.commit("update_a_msg_info", resp.message) + context.commit("update_a_open_dialog_info", true) + } else { + context.commit("update_a_search_status", 2) + context.commit("update_a_search_error_message", "") + context.commit("update_a_msg_info", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_a_a_coas", data.records) + context.commit("update_a_total_coa", data.total) + } + } catch (e) { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", e.message) + context.commit("update_a_msg_info", e.message) + context.commit("update_a_open_dialog_info", true) + } + }, + // add data + async add_data(context, payload) { + context.commit("update_a_save_status", 1) + try { + let prm = {}; + prm.token = one_token() + prm.a_nat_group = payload.a_nat_group_param + prm.a_coa_uang_muka = payload.a_coa_uang_muka_param + prm.a_coa_hutang = payload.a_coa_hutang_param + prm.a_coa_disc_pendapatan = payload.a_coa_disc_pendapatan_param + prm.a_coa_retur_pendapatan = payload.a_coa_retur_pendapatan_param + + let resp = await api.addData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Add Data COA Mapping Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_add_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + // delete data + async delete_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteData(prm) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Coa " + prm.Nat_GroupName + " berhasil dihapus" + context.commit("update_a_msg_success", msg) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + // get_by_id + async get_by_id(context, payload) { + context.commit("update_e_loading_nat_group", true) + try { + let prm = {}; + prm.token = one_token() + // map group + prm.MapNatGroup_ID = payload.MapNatGroup_ID + // group + prm.MapNatGroup_NatGroupID = payload.MapNatGroup_NatGroupID + // uang muka + prm.MapNatGroup_Dp_coaID = payload.MapNatGroup_Dp_coaID + // hutang + prm.MapNatGroup_Debt_coaID = payload.MapNatGroup_Debt_coaID + // disc pendapatan + prm.MapNatGroup_Disc_coaID = payload.MapNatGroup_Disc_coaID + // retur + prm.MapNatGroup_Retur_coaID = payload.MapNatGroup_Retur_coaID + + let resp = await api.getByID(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_nat_group", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_nat_group", true) + + // MapNatGroup_ID + context.commit("update_MapNatGroup_ID", resp.data.record_map_nat_group[0].MapNatGroup_ID) + + // nat_group + context.commit("update_e_nat_group_list", resp.data.records_group_all) + context.commit("update_e_nat_group",{ + Nat_GroupCode: resp.data.records_group[0].Nat_GroupCode, + Nat_GroupID: resp.data.records_group[0].Nat_GroupID, + Nat_GroupName: resp.data.records_group[0].Nat_GroupName + }) + + // uang muka + context.commit("update_e_coa_uang_muka_list", resp.data.records_uang_muka) + context.commit("update_e_coa_uang_muka",{ + coaID: resp.data.records_uang_muka[0].coaID, + coaAccountNo: resp.data.records_uang_muka[0].coaAccountNo, + coaDescription: resp.data.records_uang_muka[0].coaDescription, + coaSubDescription: resp.data.records_uang_muka[0].coaSubDescription, + coaAccountType: resp.data.records_uang_muka[0].coaAccountType, + coaSpecialAccountType: resp.data.records_uang_muka[0].coaSpecialAccountType, + coaIsInput: resp.data.records_uang_muka[0].coaIsInput, + coaReportSchedule: resp.data.records_uang_muka[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_uang_muka[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_uang_muka[0].coaCashFlowCategory, + coaCreated: resp.data.records_uang_muka[0].coaCreated, + coaLastUpdated: resp.data.records_uang_muka[0].coaLastUpdated, + coaIsActive: resp.data.records_uang_muka[0].coaIsActive, + coaLevel: resp.data.records_uang_muka[0].coaLevel + }) + + // hutang + context.commit("update_e_coa_hutang_list", resp.data.records_hutang) + context.commit("update_e_coa_hutang",{ + coaID: resp.data.records_hutang[0].coaID, + coaAccountNo: resp.data.records_hutang[0].coaAccountNo, + coaDescription: resp.data.records_hutang[0].coaDescription, + coaSubDescription: resp.data.records_hutang[0].coaSubDescription, + coaAccountType: resp.data.records_hutang[0].coaAccountType, + coaSpecialAccountType: resp.data.records_hutang[0].coaSpecialAccountType, + coaIsInput: resp.data.records_hutang[0].coaIsInput, + coaReportSchedule: resp.data.records_hutang[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_hutang[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_hutang[0].coaCashFlowCategory, + coaCreated: resp.data.records_hutang[0].coaCreated, + coaLastUpdated: resp.data.records_hutang[0].coaLastUpdated, + coaIsActive: resp.data.records_hutang[0].coaIsActive, + coaLevel: resp.data.records_hutang[0].coaLevel + }) + + // disc. pendapatan + context.commit("update_e_coa_disc_pendapatan_list", resp.data.records_disc) + context.commit("update_e_coa_disc_pendapatan",{ + coaID: resp.data.records_disc[0].coaID, + coaAccountNo: resp.data.records_disc[0].coaAccountNo, + coaDescription: resp.data.records_disc[0].coaDescription, + coaSubDescription: resp.data.records_disc[0].coaSubDescription, + coaAccountType: resp.data.records_disc[0].coaAccountType, + coaSpecialAccountType: resp.data.records_disc[0].coaSpecialAccountType, + coaIsInput: resp.data.records_disc[0].coaIsInput, + coaReportSchedule: resp.data.records_disc[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_disc[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_disc[0].coaCashFlowCategory, + coaCreated: resp.data.records_disc[0].coaCreated, + coaLastUpdated: resp.data.records_disc[0].coaLastUpdated, + coaIsActive: resp.data.records_disc[0].coaIsActive, + coaLevel: resp.data.records_disc[0].coaLevel + }) + + // retur + context.commit("update_e_coa_retur_pendapatan_list", resp.data.records_retur) + context.commit("update_e_coa_retur_pendapatan",{ + coaID: resp.data.records_retur[0].coaID, + coaAccountNo: resp.data.records_retur[0].coaAccountNo, + coaDescription: resp.data.records_retur[0].coaDescription, + coaSubDescription: resp.data.records_retur[0].coaSubDescription, + coaAccountType: resp.data.records_retur[0].coaAccountType, + coaSpecialAccountType: resp.data.records_retur[0].coaSpecialAccountType, + coaIsInput: resp.data.records_retur[0].coaIsInput, + coaReportSchedule: resp.data.records_retur[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_retur[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_retur[0].coaCashFlowCategory, + coaCreated: resp.data.records_retur[0].coaCreated, + coaLastUpdated: resp.data.records_retur[0].coaLastUpdated, + coaIsActive: resp.data.records_retur[0].coaIsActive, + coaLevel: resp.data.records_retur[0].coaLevel + }) + + context.commit("update_dialog_edit_coa",true) + } + } catch (e) { + context.commit("update_e_loading_nat_group", false) + } + }, + + // edit data + async edit_data(context, payload) { + context.commit("update_a_save_status", 1) + try { + let prm = {}; + prm.token = one_token() + prm.MapNatGroup_ID = payload.MapNatGroup_ID + prm.e_nat_group = payload.e_nat_group_param + prm.e_coa_uang_muka = payload.e_coa_uang_muka_param + prm.e_coa_hutang = payload.e_coa_hutang_param + prm.e_coa_disc_pendapatan = payload.e_coa_disc_pendapatan_param + prm.e_coa_retur_pendapatan = payload.e_coa_retur_pendapatan_param + + let resp = await api.editData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Edit Data COA Mapping Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_edit_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + }, +} \ No newline at end of file diff --git a/test/vuex/acc-one-map-natgroup/store.js b/test/vuex/acc-one-map-natgroup/store.js new file mode 100644 index 0000000..c20b133 --- /dev/null +++ b/test/vuex/acc-one-map-natgroup/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import a_coa from "./modules/a_coa.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + a_coa:a_coa, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-map-natsubgroup/api/natsubgroup.js b/test/vuex/acc-one-map-natsubgroup/api/natsubgroup.js new file mode 100644 index 0000000..9ed749a --- /dev/null +++ b/test/vuex/acc-one-map-natsubgroup/api/natsubgroup.js @@ -0,0 +1,192 @@ +const URL = "/one-api/map/Natsubgroup"; + +export async function getNatGroup(prm) { + try { + var resp = await axios.post(URL + '/getNatGroup', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getNatSubGroup(prm) { + try { + var resp = await axios.post(URL + '/getNatSubGroup', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAcPendapatan(prm) { + try { + var resp = await axios.post(URL + '/getAcPendapatan', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAcBiaya(prm) { + try { + var resp = await axios.post(URL + '/getAcBiaya', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAcPersediaan(prm) { + try { + var resp = await axios.post(URL + '/getAcPersediaan', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search(prm) { + try { + var resp = await axios.post(URL + "/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function addData(prm) { + try { + var resp = await axios.post(URL + '/addData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getByID(prm) { + try { + var resp = await axios.post(URL + '/get_by_id', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editData(prm) { + try { + var resp = await axios.post(URL + '/editData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteData(prm) { + try { + var resp = await axios.post(URL + '/deleteData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-map-natsubgroup/components/natsubgroup.vue b/test/vuex/acc-one-map-natsubgroup/components/natsubgroup.vue new file mode 100644 index 0000000..faeea3b --- /dev/null +++ b/test/vuex/acc-one-map-natsubgroup/components/natsubgroup.vue @@ -0,0 +1,912 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-map-natsubgroup/modules/natsubgroup.js b/test/vuex/acc-one-map-natsubgroup/modules/natsubgroup.js new file mode 100644 index 0000000..839ec16 --- /dev/null +++ b/test/vuex/acc-one-map-natsubgroup/modules/natsubgroup.js @@ -0,0 +1,695 @@ +import * as api from "../api/natsubgroup.js" + +export default { + namespaced: true, + state: { + MapNatSub_ID: 0, + a_errors_save_nat_subgroup: [], + a_save_status: 0, + a_loading_nat_group: false, + e_loading_nat_group: false, + a_loading_nat_subgroup: false, + a_alert_success: false, + a_msg_success: '', + a_alert_error: false, + a_save_error_message: '', + dialog_add_coa: false, + dialog_edit_coa: false, + a_msg_info: '', + a_open_dialog_info: false, + a_loading_coa_pendapatan: false, + e_loading_coa_pendapatan: false, + a_loading_coa_biaya: false, + e_loading_coa_biaya: false, + a_search_status: 0, + a_coas: [], + a_errors_save_coa: [], + a_selected_a_coa: {}, + // search table + a_x_search: '', + a_current_page: 1, + a_last_id: -1, + a_total_coa: 0, + // search table + // dropdown add nat_group + a_nat_group_list: [], + a_nat_group: {}, + e_nat_group_list: [], + e_nat_group: {}, + // dropdown add nat_subgroup + a_nat_subgroup_list: [], + a_nat_subgroup: {}, + e_nat_subgroup_list: [], + e_nat_subgroup: {}, + // ac pendapatan + a_coa_pendapatan_list: [], + a_coa_pendapatan: {}, + a_coa_search_pendapatan: '', + + e_coa_pendapatan_list: [], + e_coa_pendapatan: {}, + e_coa_search_pendapatan: '', + // ac biaya + a_coa_biaya_list: [], + a_coa_biaya: {}, + a_coa_search_biaya: '', + + e_coa_biaya_list: [], + e_coa_biaya: {}, + e_coa_search_biaya: '', + // ac persediaan + a_coa_persediaan_list: [], + a_coa_persediaan: {}, + a_coa_search_persediaan: '', + + e_coa_persediaan_list: [], + e_coa_persediaan: {}, + e_coa_search_persediaan: '', + }, + mutations: { + update_dialog_edit_coa(state, val) { + state.dialog_edit_coa = val + }, + update_e_loading_nat_group(state, val) { + state.e_loading_nat_group = val + }, + update_a_selected_a_coa(state, val) { + state.a_selected_a_coa = val + }, + update_a_errors_save_coa(state, val) { + state.a_errors_save_coa = val + }, + update_MapNatSub_ID(state, val) { + state.MapNatSub_ID = val + }, + update_a_open_dialog_info(state, val) { + state.a_open_dialog_info = val + }, + update_a_msg_info(state, val) { + state.a_msg_info = val + }, + update_a_alert_success(state, val) { + state.a_alert_success = val + }, + update_a_msg_success(state, val) { + state.a_msg_success = val + }, + update_a_alert_error(state, val) { + state.a_alert_error = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + //table + update_a_search_error_message(state, val) { + state.a_search_error_message = val + }, + update_a_search_status(state, val) { + state.a_search_status = val + }, + update_a_x_search(state, val) { + state.a_x_search = val + }, + update_a_current_page(state, val) { + state.a_current_page = val + }, + update_a_last_id(state, val) { + state.a_last_id = val + }, + update_a_total_coa(state, val) { + state.a_total_coa = val + }, + update_a_a_coas(state, val) { + state.a_coas = val + }, + + // nat_group + update_a_loading_nat_group(state, val) { + state.a_loading_nat_group = val + }, + update_a_nat_group_list(state, val) { + state.a_nat_group_list = val + }, + update_a_nat_group(state, val) { + state.a_nat_group = val + }, + update_e_nat_group_list(state, val) { + state.e_nat_group_list = val + }, + update_e_nat_group(state, val) { + state.e_nat_group = val + }, + + // nat_subgroup + update_a_loading_nat_subgroup(state, val) { + state.a_loading_nat_subgroup = val + }, + update_a_nat_subgroup_list(state, val) { + state.a_nat_subgroup_list = val + }, + update_a_nat_subgroup(state, val) { + state.a_nat_subgroup = val + }, + + update_e_nat_subgroup_list(state, val) { + state.e_nat_subgroup_list = val + }, + update_e_nat_subgroup(state, val) { + state.e_nat_subgroup = val + }, + + // pendapatan + update_a_loading_coa_pendapatan(state, val) { + state.a_loading_coa_pendapatan = val + }, + update_e_loading_coa_pendapatan(state, val) { + state.e_loading_coa_pendapatan = val + }, + update_a_coa_pendapatan_list(state, val) { + state.a_coa_pendapatan_list = val + }, + update_e_coa_pendapatan_list(state, val) { + state.e_coa_pendapatan_list = val + }, + update_a_coa_pendapatan(state, val) { + state.a_coa_pendapatan = val + }, + update_e_coa_pendapatan(state, val) { + state.e_coa_pendapatan = val + }, + update_a_coa_search_pendapatan(state, val) { + state.a_coa_search_pendapatan = val + }, + update_e_coa_search_pendapatan(state, val) { + state.e_coa_search_pendapatan = val + }, + // biaya + update_a_loading_coa_biaya(state, val) { + state.a_loading_coa_biaya = val + }, + update_a_coa_biaya_list(state, val) { + state.a_coa_biaya_list = val + }, + update_a_coa_biaya(state, val) { + state.a_coa_biaya = val + }, + update_a_coa_search_biaya(state, val) { + state.a_coa_search_biaya = val + }, + + update_e_loading_coa_biaya(state, val) { + state.e_loading_coa_biaya = val + }, + update_e_coa_biaya_list(state, val) { + state.e_coa_biaya_list = val + }, + update_e_coa_biaya(state, val) { + state.e_coa_biaya = val + }, + update_e_coa_search_biaya(state, val) { + state.e_coa_search_biaya = val + }, + // persediaan + update_a_loading_coa_persediaan(state, val) { + state.a_loading_coa_persediaan = val + }, + update_e_loading_coa_persediaan(state, val) { + state.e_loading_coa_persediaan = val + }, + update_a_coa_persediaan_list(state, val) { + state.a_coa_persediaan_list = val + }, + update_e_coa_persediaan_list(state, val) { + state.e_coa_persediaan_list = val + }, + update_a_coa_persediaan(state, val) { + state.a_coa_persediaan = val + }, + update_e_coa_persediaan(state, val) { + state.e_coa_persediaan = val + }, + update_a_coa_search_persediaan(state, val) { + state.a_coa_search_persediaan = val + }, + update_e_coa_search_persediaan(state, val) { + state.e_coa_search_persediaan = val + }, + + + update_a_save_status(state, val) { + state.a_save_status = val + }, + update_a_save_error_message(state, val) { + state.a_save_error_message = val + }, + update_a_errors_save_nat_subgroup(state, val) { + state.a_errors_save_nat_subgroup = val + }, + }, + actions: { + // get nat_group from api + async open_add_nat_group(context) { + context.commit("update_a_loading_nat_group", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getNatGroup(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_nat_group", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_nat_group", false) + context.commit("update_a_nat_group_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_nat_group", false) + } + }, + + // get nat_subgroup from api + async open_add_nat_subgroup(context) { + context.commit("update_a_loading_nat_subgroup", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getNatSubGroup(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_nat_subgroup", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_nat_subgroup", false) + context.commit("update_a_nat_subgroup_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_nat_subgroup", false) + } + }, + + // get ac pendapatan from api + async open_add_coa_pendapatan(context, payload) { + context.commit("update_a_loading_coa_pendapatan", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcPendapatan(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_pendapatan", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_pendapatan", false) + context.commit("update_a_coa_pendapatan_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_pendapatan", false) + } + }, + + async open_edit_coa_pendapatan(context, payload) { + context.commit("update_a_loading_coa_pendapatan", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcPendapatan(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_pendapatan", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_pendapatan", false) + context.commit("update_e_coa_pendapatan_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_pendapatan", false) + } + }, + + // get ac biaya from api + async open_add_coa_biaya(context, payload) { + context.commit("update_a_loading_coa_biaya", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcBiaya(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_biaya", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_biaya", false) + context.commit("update_a_coa_biaya_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_biaya", false) + } + }, + + async open_edit_coa_biaya(context, payload) { + context.commit("update_a_loading_coa_biaya", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcBiaya(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_biaya", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_biaya", false) + context.commit("update_e_coa_biaya_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_biaya", false) + } + }, + + // get ac persediaan from api + async open_add_coa_persediaan(context, payload) { + context.commit("update_a_loading_coa_persediaan", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcPersediaan(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_persediaan", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_persediaan", false) + context.commit("update_a_coa_persediaan_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_persediaan", false) + } + }, + + async open_edit_coa_persediaan(context, payload) { + context.commit("update_a_loading_coa_persediaan", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcPersediaan(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_coa_persediaan", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_coa_persediaan", false) + context.commit("update_e_coa_persediaan_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_coa_persediaan", false) + } + }, + + // add data + async add_data(context, payload) { + context.commit("update_a_save_status", 1) + try { + let prm = {}; + prm.token = one_token() + prm.a_nat_group = payload.a_nat_group_param + prm.a_nat_subgroup = payload.a_nat_subgroup_param + prm.a_coa_pendapatan = payload.a_coa_pendapatan_param + prm.a_coa_biaya = payload.a_coa_biaya_param + prm.a_coa_persediaan = payload.a_coa_persediaan_param + + let resp = await api.addData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Add Data Nat Sub Group COA Mapping Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_add_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + + context.commit("update_a_nat_group", {}); + context.commit("update_a_nat_subgroup", {}); + context.commit("update_a_coa_pendapatan", {}); + context.commit("update_a_coa_biaya", {}); + context.commit("update_a_coa_persediaan", {}); + } else { + context.commit("update_a_errors_save_nat_subgroup", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + + // search + async search(context, prm) { + context.commit("update_a_search_status", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", resp.message) + context.commit("update_a_msg_info", resp.message) + context.commit("update_a_open_dialog_info", true) + } else { + context.commit("update_a_search_status", 2) + context.commit("update_a_search_error_message", "") + context.commit("update_a_msg_info", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_a_a_coas", data.records) + context.commit("update_a_total_coa", data.total) + } + } catch (e) { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", e.message) + context.commit("update_a_msg_info", e.message) + context.commit("update_a_open_dialog_info", true) + } + }, + + // get_by_id + async get_by_id(context, payload) { + context.commit("update_e_loading_nat_group", true) + try { + let prm = {}; + prm.token = one_token() + // map group + prm.MapNatSub_ID = payload.MapNatSub_ID + // group + prm.MapNatSub_NatGroupID = payload.MapNatSub_NatGroupID + // sub_grup + prm.MapNatSub_NatSubGroupID = payload.MapNatSub_NatSubGroupID + // pendapatan + prm.MapNatSub_PendapatanCoaID = payload.MapNatSub_PendapatanCoaID + // biaya + prm.MapNatSub_BiayaCoaID = payload.MapNatSub_BiayaCoaID + // persediaan + prm.MapNatSub_PersediaanCoaID = payload.MapNatSub_PersediaanCoaID + + let resp = await api.getByID(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_nat_group", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_nat_group", true) + + // MapNatGroup_ID + context.commit("update_MapNatSub_ID", resp.data.record_map_nat_subgroup[0].MapNatSub_ID) + + // nat_group + context.commit("update_e_nat_group_list", resp.data.records_group_all) + context.commit("update_e_nat_group", { + Nat_GroupCode: resp.data.records_group[0].Nat_GroupCode, + Nat_GroupID: resp.data.records_group[0].Nat_GroupID, + Nat_GroupName: resp.data.records_group[0].Nat_GroupName + }) + + // nat_subgroup + context.commit("update_e_nat_subgroup_list", resp.data.records_sub_group_all) + context.commit("update_e_nat_subgroup", { + Nat_SubGroupCode: resp.data.records_sub_group[0].Nat_SubGroupCode, + Nat_SubGroupID: resp.data.records_sub_group[0].Nat_SubGroupID, + Nat_SubGroupName: resp.data.records_sub_group[0].Nat_SubGroupName, + display: resp.data.records_sub_group[0].display, + }) + + // pendapatan + context.commit("update_e_coa_pendapatan_list", resp.data.records_pendapatan) + context.commit("update_e_coa_pendapatan", { + coaID: resp.data.records_pendapatan[0].coaID, + coaAccountNo: resp.data.records_pendapatan[0].coaAccountNo, + coaDescription: resp.data.records_pendapatan[0].coaDescription, + coaSubDescription: resp.data.records_pendapatan[0].coaSubDescription, + coaAccountType: resp.data.records_pendapatan[0].coaAccountType, + coaSpecialAccountType: resp.data.records_pendapatan[0].coaSpecialAccountType, + coaIsInput: resp.data.records_pendapatan[0].coaIsInput, + coaReportSchedule: resp.data.records_pendapatan[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_pendapatan[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_pendapatan[0].coaCashFlowCategory, + coaCreated: resp.data.records_pendapatan[0].coaCreated, + coaLastUpdated: resp.data.records_pendapatan[0].coaLastUpdated, + coaIsActive: resp.data.records_pendapatan[0].coaIsActive, + coaLevel: resp.data.records_pendapatan[0].coaLevel + }) + + // biaya + context.commit("update_e_coa_biaya_list", resp.data.records_biaya) + context.commit("update_e_coa_biaya", { + coaID: resp.data.records_biaya[0].coaID, + coaAccountNo: resp.data.records_biaya[0].coaAccountNo, + coaDescription: resp.data.records_biaya[0].coaDescription, + coaSubDescription: resp.data.records_biaya[0].coaSubDescription, + coaAccountType: resp.data.records_biaya[0].coaAccountType, + coaSpecialAccountType: resp.data.records_biaya[0].coaSpecialAccountType, + coaIsInput: resp.data.records_biaya[0].coaIsInput, + coaReportSchedule: resp.data.records_biaya[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_biaya[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_biaya[0].coaCashFlowCategory, + coaCreated: resp.data.records_biaya[0].coaCreated, + coaLastUpdated: resp.data.records_biaya[0].coaLastUpdated, + coaIsActive: resp.data.records_biaya[0].coaIsActive, + coaLevel: resp.data.records_biaya[0].coaLevel + }) + + // persediaan + context.commit("update_e_coa_persediaan_list", resp.data.records_persediaan) + context.commit("update_e_coa_persediaan", { + coaID: resp.data.records_persediaan[0].coaID, + coaAccountNo: resp.data.records_persediaan[0].coaAccountNo, + coaDescription: resp.data.records_persediaan[0].coaDescription, + coaSubDescription: resp.data.records_persediaan[0].coaSubDescription, + coaAccountType: resp.data.records_persediaan[0].coaAccountType, + coaSpecialAccountType: resp.data.records_persediaan[0].coaSpecialAccountType, + coaIsInput: resp.data.records_persediaan[0].coaIsInput, + coaReportSchedule: resp.data.records_persediaan[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_persediaan[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_persediaan[0].coaCashFlowCategory, + coaCreated: resp.data.records_persediaan[0].coaCreated, + coaLastUpdated: resp.data.records_persediaan[0].coaLastUpdated, + coaIsActive: resp.data.records_persediaan[0].coaIsActive, + coaLevel: resp.data.records_persediaan[0].coaLevel + }) + + context.commit("update_dialog_edit_coa", true) + } + } catch (e) { + context.commit("update_e_loading_nat_group", false) + } + }, + + // edit data + async edit_data(context, payload) { + context.commit("update_a_save_status", 1) + try { + let prm = {}; + prm.token = one_token() + prm.MapNatSub_ID = payload.MapNatSub_ID + prm.e_nat_group = payload.e_nat_group_param + prm.e_nat_subgroup = payload.e_nat_subgroup_param + prm.e_coa_biaya = payload.e_coa_biaya_param + prm.e_coa_pendapatan = payload.e_coa_pendapatan_param + prm.e_coa_persediaan = payload.e_coa_persediaan_param + + let resp = await api.editData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Edit Data National SUb Grup COA Mapping Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_edit_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + + // delete data + async delete_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteData(prm) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Coa " + prm.Nat_GroupName + " berhasil dihapus" + context.commit("update_a_msg_success", msg) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + }, + +} \ No newline at end of file diff --git a/test/vuex/acc-one-map-natsubgroup/store.js b/test/vuex/acc-one-map-natsubgroup/store.js new file mode 100644 index 0000000..a758d9d --- /dev/null +++ b/test/vuex/acc-one-map-natsubgroup/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import natsubgroup from "./modules/natsubgroup.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + natsubgroup:natsubgroup, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-map-rk-cabang/api/bank.js b/test/vuex/acc-one-map-rk-cabang/api/bank.js new file mode 100644 index 0000000..bb42cce --- /dev/null +++ b/test/vuex/acc-one-map-rk-cabang/api/bank.js @@ -0,0 +1,204 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getRegional(token, prm) { + try { + var resp = await axios.post(URL + "maprk/getRegional", { + token: token, + search: prm + }); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getRegionalFilter(prm) { + try { + var resp = await axios.post(URL + "maprk/getRegionalFilter", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "maprk/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getBranchFilter(prm) { + try { + var resp = await axios.post(URL + "maprk/getBranchFilter", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function search(prm) { + try { + var resp = await axios.post(URL + "maprk/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getType(token, prm) { + try { + var resp = await axios.post(URL + 'maprk/getType', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchCoaEDC(token, prm) { + try { + var resp = await axios.post(URL + 'maprk/searchCoaEDC', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveRkCabang(prm) { + try { + var resp = await axios.post(URL + 'maprk/saveRkCabang', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function updateRkCabang(prm) { + try { + var resp = await axios.post(URL + 'maprk/updateRkCabang', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteRkCabang(prm) { + try { + var resp = await axios.post(URL + 'maprk/deleteRkCabang', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-map-rk-cabang/components/oneRKCabangList.vue b/test/vuex/acc-one-map-rk-cabang/components/oneRKCabangList.vue new file mode 100644 index 0000000..44be382 --- /dev/null +++ b/test/vuex/acc-one-map-rk-cabang/components/oneRKCabangList.vue @@ -0,0 +1,807 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-map-rk-cabang/modules/bank.js b/test/vuex/acc-one-map-rk-cabang/modules/bank.js new file mode 100644 index 0000000..6ccf880 --- /dev/null +++ b/test/vuex/acc-one-map-rk-cabang/modules/bank.js @@ -0,0 +1,420 @@ +import * as api from "../api/bank.js" + +export default { + namespaced: true, + state: { + autocomplete_status: 0, + search_error_message: "", + regionals: [], + selected_regional: {}, + search_regional: "", + autocomplete_status_regional: 0, + regional_filters: [], + selected_regional_filter: {}, + branchs: [], + selected_branch: {}, + branch_filters: [], + selected_branch_filter: {}, + search_status: "", + rkcabangs: [], + selected_rkcabang: {}, + total_page: 0, + current_page: 1, + open_dialog_info: false, + msg_info: "", + xsearch: "", + dialog_form: false, + coa_edc_list: [], + selected_edc_coa: {}, + search_coa_edc: "", + autocomplete_status_type: 0, + isEDC: false, + save_status: 0, + save_error_message: "", + alert_error: false, + alert_success: false, + errors_save: [], + msg_success: "", + act: "new", + type_list: [], + selected_type: {}, + autocomplete_status_type: 0, + search_type: "" + }, + mutations: { + update_autocomplete_status(state, val) { + state.autocomplete_status = val + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_regionals(state, val) { + state.regionals = val + }, + update_selected_regional(state, val) { + state.selected_regional = val + }, + update_search_regional(state, val) { + state.search_regional = val + }, + update_autocomplete_status_regional(state, val) { + state.autocomplete_status_regional = val + }, + update_regional_filters(state, val) { + state.regional_filters = val + }, + update_selected_regional_filter(state, val) { + state.selected_regional_filter = val + }, + update_branch_filters(state, val) { + state.branch_filters = val + }, + update_selected_branch_filter(state, val) { + state.selected_branch_filter = val + }, + update_branchs(state, val) { + state.branchs = val + }, + update_selected_branch(state, val) { + state.selected_branch = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_rkcabangs(state, val) { + state.rkcabangs = val + }, + update_selected_rkcabang(state, val) { + state.selected_rkcabang = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val + }, + update_msg_info(state, val) { + state.msg_info = val + }, + update_xsearch(state, val) { + state.xsearch = val + }, + update_dialog_form(state, val) { + state.dialog_form = val + }, + update_coa_edc_list(state, val) { + state.coa_edc_list = val + }, + update_selected_edc_coa(state, val) { + state.selected_edc_coa = val + }, + update_search_coa_edc(state, val) { + state.search_coa_edc = val + }, + update_autocomplete_status_edc(state, val) { + state.autocomplete_status_edc = val + }, + update_isEDC(state, val) { + state.isEDC = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_errors_save(state, val) { + state.errors_save = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_act(state, val) { + state.act = val + }, + update_type_list(state, val) { + state.type_list = val + }, + update_selected_type(state, val) { + state.selected_type = val + }, + update_autocomplete_status_type(state, val) { + state.autocomplete_status_type = val + }, + update_search_type(state, val) { + state.search_type = val + } + }, + actions: { + async getRegional(context, prm) { + context.commit("update_autocomplete_status_regional", 1) + try { + let resp = await api.getRegional(one_token(), prm); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_autocomplete_status_regional", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_autocomplete_status_regional", 2) + let data = { + records: resp.data.records, + }; + + context.commit("update_regionals", data.records); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_autocomplete_status_regional", 3) + } + }, + async getRegionalFilter(context) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.getRegionalFilter({ token: one_token()}); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + }; + + context.commit("update_regional_filters", data.records); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_autocomplete_status", 3) + } + }, + async getBranch(context) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.getBranch({ token: one_token(), regionalId: context.state.selected_regional.S_RegionalID}); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + }; + + context.commit("update_branchs", data.records); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_autocomplete_status", 3) + } + }, + async getBranchFilter(context) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.getBranchFilter({ token: one_token(), regionalId: context.state.selected_regional_filter.S_RegionalID}); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + }; + + context.commit("update_branch_filters", data.records); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_autocomplete_status", 3) + } + }, + async search(context, prm) { + context.commit("update_search_status", 1) + try { + prm.token = one_token() + let resp = await api.search(prm); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message) + context.commit("update_search_status", 3) + } else { + context.commit("update_search_error_message", "") + context.commit("update_search_status", 2) + let data = { + records: resp.data.records, + total_page: resp.data.total_page, + }; + + context.commit("update_rkcabangs", data.records); + context.commit("update_total_page", data.total_page); + } + } catch (e) { + context.commit("update_search_error_message", e.message) + context.commit("update_search_status", 3) + } + }, + async getType(context, prm) { + context.commit("update_autocomplete_status_type", 1) + try { + let resp = await api.getType(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status_type", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_autocomplete_status_type", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records + } + + context.commit("update_type_list", data.records) + } + } catch (e) { + context.commit("update_autocomplete_status_type", 3) + context.commit("update_search_error_message", e.message) + } + }, + async searchCoaEDC(context, prm) { + context.commit("update_autocomplete_status_edc", 1) + try { + let resp = await api.searchCoaEDC(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status_edc", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_autocomplete_status_edc", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records + } + + context.commit("update_coa_edc_list", data.records) + } + } catch (e) { + context.commit("update_autocomplete_status_edc", 3) + context.commit("update_search_error_message", e.message) + } + }, + async saveRkCabang(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.saveRkCabang(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = prm.rkCabangCoaDescription + " berhasil di tambahkan" + context.commit("update_msg_success", msg) + context.dispatch("search", { + current_page: context.state.current_page, + search: context.state.xsearch, + branchCode: prm.branchCode, + regionalId: prm.regionalId + }) + } else { + context.commit("update_errors_save", "error save") + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + async updateRkCabang(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.updateRkCabang(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = prm.rkCabangCoaDescription + " berhasil di update" + context.commit("update_msg_success", msg) + context.dispatch("search", { + current_page: context.state.current_page, + search: context.state.xsearch, + branchCode: prm.branchCode, + regionalId: prm.regionalId + }) + } else { + context.commit("update_errors_save", "update error") + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + } + }, + async deleteRkCabang(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteRkCabang(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + var msg = prm.rkCabangName + " berhasil di hapus" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.dispatch("search", { + current_page: context.state.current_page, + search: context.state.xsearch, + branchCode: prm.branchCode, + regionalId: prm.regionalId + }) + } else { + context.commit("update_errors_save", "delete error") + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + context.commit("update_save_error_message", e.message) + } + }, + }, +} \ No newline at end of file diff --git a/test/vuex/acc-one-map-rk-cabang/store.js b/test/vuex/acc-one-map-rk-cabang/store.js new file mode 100644 index 0000000..5e20992 --- /dev/null +++ b/test/vuex/acc-one-map-rk-cabang/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import bank from "./modules/bank.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + bank:bank, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-md-approve-level/api/approve.js b/test/vuex/acc-one-md-approve-level/api/approve.js new file mode 100644 index 0000000..eb4abfe --- /dev/null +++ b/test/vuex/acc-one-md-approve-level/api/approve.js @@ -0,0 +1,77 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'approvelevel/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(prm) { + try { + var resp = await axios.post(URL + 'approvelevel/save', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function update(prm) { + try { + var resp = await axios.post(URL + 'approvelevel/update', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteDep(prm) { + try { + var resp = await axios.post(URL + 'approvelevel/delete', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-md-approve-level/api/approveuser.js b/test/vuex/acc-one-md-approve-level/api/approveuser.js new file mode 100644 index 0000000..005278d --- /dev/null +++ b/test/vuex/acc-one-md-approve-level/api/approveuser.js @@ -0,0 +1,20 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getUser(prm) { + try { + var resp = await axios.post(URL + 'approvelevel/getUser', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-md-approve-level/components/oneApproveLevel.vue b/test/vuex/acc-one-md-approve-level/components/oneApproveLevel.vue new file mode 100644 index 0000000..c1fa93a --- /dev/null +++ b/test/vuex/acc-one-md-approve-level/components/oneApproveLevel.vue @@ -0,0 +1,592 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-approve-level/components/oneApproveLevelUser.vue b/test/vuex/acc-one-md-approve-level/components/oneApproveLevelUser.vue new file mode 100644 index 0000000..08dc9b0 --- /dev/null +++ b/test/vuex/acc-one-md-approve-level/components/oneApproveLevelUser.vue @@ -0,0 +1,187 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-approve-level/index.php b/test/vuex/acc-one-md-approve-level/index.php new file mode 100644 index 0000000..153f84e --- /dev/null +++ b/test/vuex/acc-one-md-approve-level/index.php @@ -0,0 +1,91 @@ + + + + + + + + One + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-approve-level/modules/approve.js b/test/vuex/acc-one-md-approve-level/modules/approve.js new file mode 100644 index 0000000..ecb2034 --- /dev/null +++ b/test/vuex/acc-one-md-approve-level/modules/approve.js @@ -0,0 +1,205 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/approve.js" + +export default { + namespaced: true, + state: { + search_status: 0, + search_error_message: "", + approvelevels: [], + selected_approvelevel: {}, + total_page: 0, + current_page: 1, + xsearch: "", + last_id: -1, + dialog_form: false, + act: "new", + errors: "", + save_status: 0, + save_error_message: "", + alert_error: false, + alert_success: false, + msg_success: "" + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_approvelevels(state, val) { + state.approvelevels = val + }, + update_selected_approvelevel(state, val) { + state.selected_approvelevel = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_xsearch(state, val) { + state.xsearch = val + state.current_page = 1 + }, + update_last_id(state, val) { + state.last_id = val + }, + update_dialog_form(state, val) { + state.dialog_form = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_errors(state, val) { + state.errors = val + }, + }, + actions: { + async search(context) { + context.commit("update_search_status", 1) + try { + var prm = { + token: one_token(), + current_page: context.state.current_page, + search: context.state.xsearch, + last_id: -1 + } + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total_page + } + + context.commit("update_approvelevels", data.records) + context.commit("update_total_page", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async save(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = `Approve level baru dengan nama ${data.records[0].M_ApproveLevelName} sudah tersimpan`; + context.commit("update_msg_success", msg) + context.dispatch("search") + context.commit("update_selected_approvelevel", data.records[0]); + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + }, + async update(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.update(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = `Approve level dengan nama ${data.records[0].M_ApproveLevelName} berhasil di update`; + context.commit("update_msg_success", msg) + context.dispatch("search") + context.commit("update_selected_approvelevel", data.records[0]); + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + }, + async deleteDep(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteDep(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + message: resp.data.message + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + context.commit("update_msg_success", data.message) + context.dispatch("search") + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-approve-level/modules/approveuser.js b/test/vuex/acc-one-md-approve-level/modules/approveuser.js new file mode 100644 index 0000000..aa5a5e6 --- /dev/null +++ b/test/vuex/acc-one-md-approve-level/modules/approveuser.js @@ -0,0 +1,76 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/approveuser.js" + +export default { + namespaced: true, + state: { + search_status: 0, + search_error_message: "", + users: [], + total_page: 0, + current_page: 1, + xsearch: "", + last_id: -1, + dialog_form: false, + act: "new", + errors: "", + save_status: 0, + save_error_message: "", + alert_error: false, + alert_success: false, + msg_success: "" + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_users(state, val) { + state.users = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_xsearch(state, val) { + state.xsearch = val + state.current_page = 1 + }, + update_last_id(state, val) { + state.last_id = val + } + }, + actions: { + async getUser(context, prm) { + context.commit("update_search_status", 1) + try { + prm.token = one_token() + let resp = await api.getUser(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total_page + } + + context.commit("update_users", data.records) + context.commit("update_total_page", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-approve-level/store.js b/test/vuex/acc-one-md-approve-level/store.js new file mode 100644 index 0000000..fc6200b --- /dev/null +++ b/test/vuex/acc-one-md-approve-level/store.js @@ -0,0 +1,13 @@ +import approve from "./modules/approve.js"; +import approveuser from "./modules/approveuser.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + approve: approve, + approveuser: approveuser, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-md-coa/api/coa.js b/test/vuex/acc-one-md-coa/api/coa.js new file mode 100644 index 0000000..4f853f9 --- /dev/null +++ b/test/vuex/acc-one-md-coa/api/coa.js @@ -0,0 +1,77 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/addnewcoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function update(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/editcoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(token,coaid) { + try { + var resp = await axios.post(URL + 'mdcoa/deletecoa', { coaid: coaid, token:token }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-coa/components/oneMdCoaList.vue b/test/vuex/acc-one-md-coa/components/oneMdCoaList.vue new file mode 100644 index 0000000..a4c788d --- /dev/null +++ b/test/vuex/acc-one-md-coa/components/oneMdCoaList.vue @@ -0,0 +1,757 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-coa/index.php b/test/vuex/acc-one-md-coa/index.php new file mode 100644 index 0000000..7b1a3b0 --- /dev/null +++ b/test/vuex/acc-one-md-coa/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-coa/modules/coa.js b/test/vuex/acc-one-md-coa/modules/coa.js new file mode 100644 index 0000000..73aeb3b --- /dev/null +++ b/test/vuex/acc-one-md-coa/modules/coa.js @@ -0,0 +1,217 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/coa.js" + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: 'new', + save_status: 0, + save_error_message: '', + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_x_search(state, val) { + state.x_search = val + state.current_page = 1 + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_coas(state, val) { + state.coas = val + }, + update_total_coas(state, val) { + state.total_coas = val + }, + update_selected_coa(state, val) { + state.selected_coa = val + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_errors(state, val) { + state.errors = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_dialog_error(state, val) { + state.dialog_error = val + }, + update_open_print(state, value) { + state.open_print = value + } + }, + actions: { + async search(context) { + context.commit("update_search_status", 1) + try { + var prm = { + token: one_token(), + current_page: context.state.current_page, + search: context.state.x_search, + last_id: -1 + } + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_coas", data.records) + context.commit("update_total_coas", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async save(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + var data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form_coa", false) + var msg =" Account " + prm.description + " sudah tersimpan dong ..." + context.commit("update_msg_success", msg) + context.dispatch("search") + } else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + console.log(e) + } + }, + async update(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.update(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_form_coa", false) + var msg = " Account " + prm.description + " sudah terupdate dong ..." + context.commit("update_msg_success", msg) + context.dispatch("search") + }else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + console.log(e) + } + }, + + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + let resp = await api.xdelete(one_token(), prm.coaid) + console.log(prm.coid) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_success", true) + + var msg = " Account " + prm.description + " sudah dihapus dong" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.commit("update_selected_coa", {}) + context.dispatch("search") + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + console.log(e) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-coa/store.js b/test/vuex/acc-one-md-coa/store.js new file mode 100644 index 0000000..a307d3e --- /dev/null +++ b/test/vuex/acc-one-md-coa/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import coa from "./modules/coa.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + coa: coa, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-md-departement/api/departemen.js b/test/vuex/acc-one-md-departement/api/departemen.js new file mode 100644 index 0000000..050011d --- /dev/null +++ b/test/vuex/acc-one-md-departement/api/departemen.js @@ -0,0 +1,77 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'departement/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(prm) { + try { + var resp = await axios.post(URL + 'departement/save', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function update(prm) { + try { + var resp = await axios.post(URL + 'departement/update', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteDep(prm) { + try { + var resp = await axios.post(URL + 'departement/delete', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-md-departement/components/oneDepartement.vue b/test/vuex/acc-one-md-departement/components/oneDepartement.vue new file mode 100644 index 0000000..f69e05b --- /dev/null +++ b/test/vuex/acc-one-md-departement/components/oneDepartement.vue @@ -0,0 +1,479 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-departement/index.php b/test/vuex/acc-one-md-departement/index.php new file mode 100644 index 0000000..918a93a --- /dev/null +++ b/test/vuex/acc-one-md-departement/index.php @@ -0,0 +1,87 @@ + + + + + + + + One + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-departement/modules/departemen.js b/test/vuex/acc-one-md-departement/modules/departemen.js new file mode 100644 index 0000000..83cf2fb --- /dev/null +++ b/test/vuex/acc-one-md-departement/modules/departemen.js @@ -0,0 +1,205 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/departemen.js" + +export default { + namespaced: true, + state: { + search_status: 0, + search_error_message: "", + departements: [], + selected_departement: {}, + total_page: 0, + current_page: 1, + xsearch: "", + last_id: -1, + dialog_form: false, + act: "new", + errors: "", + save_status: 0, + save_error_message: "", + alert_error: false, + alert_success: false, + msg_success: "" + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_departements(state, val) { + state.departements = val + }, + update_selected_departement(state, val) { + state.selected_departement = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_xsearch(state, val) { + state.xsearch = val + state.current_page = 1 + }, + update_last_id(state, val) { + state.last_id = val + }, + update_dialog_form(state, val) { + state.dialog_form = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_errors(state, val) { + state.errors = val + }, + }, + actions: { + async search(context) { + context.commit("update_search_status", 1) + try { + var prm = { + token: one_token(), + current_page: context.state.current_page, + search: context.state.xsearch, + last_id: -1 + } + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total_page + } + + context.commit("update_departements", data.records) + context.commit("update_total_page", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async save(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = `Departement baru dengan kode ${data.records[0].M_DepartmentCode} sudah tersimpan`; + context.commit("update_msg_success", msg) + context.dispatch("search") + context.commit("update_selected_departement", data.records[0]); + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + }, + async update(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.update(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = `Departement dengan kode ${data.records[0].M_DepartmentCode} berhasil di update`; + context.commit("update_msg_success", msg) + context.dispatch("search") + context.commit("update_selected_departement", data.records[0]); + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + }, + async deleteDep(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteDep(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + message: resp.data.message + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + context.commit("update_msg_success", data.message) + context.dispatch("search") + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-departement/store.js b/test/vuex/acc-one-md-departement/store.js new file mode 100644 index 0000000..11bd023 --- /dev/null +++ b/test/vuex/acc-one-md-departement/store.js @@ -0,0 +1,11 @@ +import departemen from "./modules/departemen.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + departemen: departemen, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-md-divisi/api/divisi.js b/test/vuex/acc-one-md-divisi/api/divisi.js new file mode 100644 index 0000000..1c640d4 --- /dev/null +++ b/test/vuex/acc-one-md-divisi/api/divisi.js @@ -0,0 +1,80 @@ +// const URL = "/one-api/v1/masterdata/"; +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function lookupbyname(prm) { + try { + var resp = await axios.post(URL + 'divisi/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function add(prm) { + try { + var resp = await axios.post(URL + 'divisi/add', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(token,id) { + try { + var resp = await axios.post(URL + 'divisi/delete', + { id: id, token:token }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +// edit +export async function edit(prm) { + try { + var resp = await axios.post(URL + 'divisi/edit', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-divisi/components/oneMdItemDivisi.vue b/test/vuex/acc-one-md-divisi/components/oneMdItemDivisi.vue new file mode 100644 index 0000000..bf504f6 --- /dev/null +++ b/test/vuex/acc-one-md-divisi/components/oneMdItemDivisi.vue @@ -0,0 +1,624 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-divisi/index.php b/test/vuex/acc-one-md-divisi/index.php new file mode 100644 index 0000000..779c536 --- /dev/null +++ b/test/vuex/acc-one-md-divisi/index.php @@ -0,0 +1,78 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/acc-one-md-divisi/modules/divisi.js b/test/vuex/acc-one-md-divisi/modules/divisi.js new file mode 100644 index 0000000..1b29a12 --- /dev/null +++ b/test/vuex/acc-one-md-divisi/modules/divisi.js @@ -0,0 +1,263 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/divisi.js" + +export default { + namespaced: true, + state: { + lookup_error_message:'', + lookup_unit:0, + divisions:[], + total_divisions:0, + total_filter_divisions:0, + current_page:1, + x_search: '', + autocomplete_status: 0, + pagination:{ + descending:'asc', + sortBy:'DivisionCode' + }, + search_status: false, + + dialog_form_division: false, + alert_success: false, + msg_success: "", + show_all: 'N', + errors: [], + act: 'new', + + selected_division: { + name: "" + }, + save_status: 0, + save_error_message: '', + dialogdeletealert: false, + action_delete: false + }, + mutations: { + update_dialogdeletealert(state, val) { + state.dialogdeletealert = val + if(val == false){ + state.action_delete = false + } + }, + update_action_delete(state, val) { + state.action_delete = val + }, + update_total_divisions(state, val) { + state.total_divisions = val + }, + update_total_filter_divisions(state, val) { + state.total_filter_divisions = val + }, + update_lookup_error_message(state, status) { + state.lookup_error_message = status + }, + update_lookup_unit(state, status) { + state.lookup_unit = status + }, + update_divisions(state, data) { + state.divisions = data + }, + update_current_page(state, val) { + state.current_page = val + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_pagination(state, val) { + state.pagination = val + }, + + update_dialog_form_division(state, val) { + console.log(state, val); + state.dialog_form_division = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_errors(state, val) { + state.errors = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_act(state, val) { + state.act = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_selected_division(state, val) { + state.selected_division = val + }, + update_x_search(state, val) { + state.x_search = val + state.current_page = 1; + }, + }, + actions: { + // load data dan search + async lookupbyname(context, prm) { + context.commit("update_lookup_unit", 1) + context.commit("update_search_status", true) + try { + // prm.token = one_token() + var prm = { + // query:context.state.xsearch, + current_page:context.state.current_page, + // last_id:context.state.last_id, + search:context.state.x_search, + sortBy:context.state.pagination.sortBy, + sortStatus:context.state.pagination.descending, + token:one_token() + } + let resp = await api.lookupbyname(prm) + if (resp.status != "OK") { + context.commit("update_search_status", false) + context.commit("update_lookup_unit", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_search_status", false) + context.commit("update_lookup_unit", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total, + total_filter: resp.data.total_filter + } + context.commit("update_divisions", data.records) + context.commit("update_total_divisions", data.total) + context.commit("update_total_filter_divisions", data.total_filter) + if(context.state.last_id != -1){ + var alldatas = resp.data.records + // var selected = _.find(alldatas, function(o) { return o.id === context.state.last_id }) + var selected = _.find(alldatas, function (o) { + return o.id === context.state.last_id; + }); + context.commit("update_selected_division", selected) + } + + } + } catch (e) { + context.commit("update_search_status", false) + context.commit("update_lookup_unit", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + + // add data + async add(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.add(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_dialogdeletealert", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_save_error_message", resp.message) + var data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form_division", false) + var msg =" Divisi " + prm.name + " sudah tersimpan dong ..." + context.commit("update_msg_success", msg) + context.dispatch("lookupbyname") + } else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + + // hapus + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + let resp = await api.xdelete(one_token(), prm.id) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_dialogdeletealert", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_success", true) + + var msg = " Divisi " + prm.name + " sudah dihapus dong" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.commit("update_action_delete", false) + // context.commit("update_selected_unit", {}) + context.dispatch("lookupbyname") + } + } catch (e) { + context.commit("update_save_status", 3) + console.log(e) + } + }, + + // edit + async edit(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.edit(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_dialogdeletealert", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + + let data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_form_division", false) + var msg = " Divisi " + prm.name + " sudah terupdate dong ..." + context.commit("update_msg_success", msg) + context.dispatch("lookupbyname") + }else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-divisi/store.js b/test/vuex/acc-one-md-divisi/store.js new file mode 100644 index 0000000..130522a --- /dev/null +++ b/test/vuex/acc-one-md-divisi/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import divisi from "./modules/divisi.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + divisi:divisi, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-md-expedition/api/expedition.js b/test/vuex/acc-one-md-expedition/api/expedition.js new file mode 100644 index 0000000..b5abc67 --- /dev/null +++ b/test/vuex/acc-one-md-expedition/api/expedition.js @@ -0,0 +1,87 @@ +const URL = "/one-api/mockup/masterdata/expedition/"; +export async function lookup(prm) { + try { + var resp = await axios.post(URL + "search", prm); + if (resp.status != 200) { + return { + status: "ERR", + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function get_staff(prm) { + try { + var resp = await axios.post(URL + "get_staff", prm); + if (resp.status != 200) { + return { + status: "ERR", + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function additem(prm) { + try { + var resp = await axios.post(URL + "add", prm); + if (resp.status != 200) { + return { + status: "ERR", + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function edititem(prm) { + try { + var resp = await axios.post(URL + "edit", prm); + if (resp.status != 200) { + return { + status: "ERR", + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteitem(prm) { + try { + var resp = await axios.post(URL + "delete", prm); + if (resp.status != 200) { + return { + status: "ERR", + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} diff --git a/test/vuex/acc-one-md-expedition/components/oneMdExpeditionList.vue b/test/vuex/acc-one-md-expedition/components/oneMdExpeditionList.vue new file mode 100644 index 0000000..4035b79 --- /dev/null +++ b/test/vuex/acc-one-md-expedition/components/oneMdExpeditionList.vue @@ -0,0 +1,949 @@ + + + diff --git a/test/vuex/acc-one-md-expedition/index.php b/test/vuex/acc-one-md-expedition/index.php new file mode 100644 index 0000000..1bb82bc --- /dev/null +++ b/test/vuex/acc-one-md-expedition/index.php @@ -0,0 +1,81 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-expedition/modules/expedition.js b/test/vuex/acc-one-md-expedition/modules/expedition.js new file mode 100644 index 0000000..2385090 --- /dev/null +++ b/test/vuex/acc-one-md-expedition/modules/expedition.js @@ -0,0 +1,227 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/expedition.js"; +export default { + namespaced: true, + state: { + expedition: [], + lookup_expedition: 2, + search_status: false, + current_page: 1, + last_id: -1, + x_search: "", + total: 0, + total_filter: 0, + selected_item: {}, + dialog_form: false, + staff: [], + save_status: 2, + error_message: "", + msg_success: "", + alert_success: false, + sorting: { + sortBy: "ExpeditionID", + type: "asc", + }, + }, + mutations: { + update_lookup_expedition(state, val) { + state.lookup_expedition = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_expedition(state, val) { + state.expedition = val.records; + state.total = val.total; + state.total_filter = val.total_filter; + }, + update_selected_item(state, val) { + state.selected_item = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_sorting(state, val) { + state.sorting = val; + }, + update_dialog_form(state, val) { + state.dialog_form = val; + }, + update_staff(state, val) { + state.staff = val.records; + }, + update_save_status(state, val) { + state.save_status = val; + }, + update_error_message(state, val) { + state.error_message = val; + }, + update_last_id(state, val) { + state.last_id = val; + }, + update_msg_success(state, val) { + state.msg_success = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + }, + actions: { + async lookup(context) { + context.commit("update_lookup_expedition", 1); + context.commit("update_search_status", true); + try { + var tkn = JSON.stringify({ + token: one_token(), + current_page: context.state.current_page, + search: context.state.x_search, + order_by: context.state.sorting.sortBy, + order_type: context.state.sorting.type, + }); + let resp = await api.lookup(tkn); + if (resp.status != "OK") { + context.commit("update_search_status", false); + context.commit("update_lookup_expedition", 3); + console.log(resp.message); + } else { + context.commit("update_search_status", false); + context.commit("update_lookup_expedition", 2); + let data = resp.data; + if (context.state.last_id == -1 && resp.data.records.length >= 1) { + context.commit("update_selected_item", resp.data.records[0]); + } else { + let idx = _.findIndex(resp.data.records, function (o) { + return o.id == context.state.last_id; + }); + if (resp.data.records[idx] != undefined) { + context.commit("update_selected_item", resp.data.records[idx]); + } else { + context.commit("update_selected_item", resp.data.records[0]); + } + } + if (resp.data.records.length < 1) { + context.commit("update_selected_item", { + id: "", + name: "", + internal: "", + staff: [], + }); + } + + context.commit("update_expedition", data); + } + } catch (e) { + context.commit("update_search_status", false); + context.commit("update_lookup_expedition", 3); + // context.commit("update_lookup_error_message", e.message); + console.log(e); + } + }, + async getStaff(context) { + context.commit("update_lookup_expedition", 1); + context.commit("update_search_status", true); + try { + var tkn = JSON.stringify({ + token: one_token(), + }); + let resp = await api.get_staff(tkn); + if (resp.status != "OK") { + context.commit("update_search_status", false); + context.commit("update_lookup_expedition", 3); + console.log(resp.message); + } else { + context.commit("update_search_status", false); + context.commit("update_lookup_expedition", 2); + let data = resp.data; + context.commit("update_staff", data); + } + } catch (e) { + context.commit("update_search_status", false); + context.commit("update_lookup_expedition", 3); + // context.commit("update_lookup_error_message", e.message); + console.log(e); + } + }, + async addData(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token(); + let resp = await api.additem(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_error_message", resp.message); + console.log(resp.message); + } else { + context.commit("update_error_message", ""); + context.commit("update_save_status", 2); + let data = resp.data; + context.dispatch("lookup"); + var msg = "Ekspedisi " + prm.name + " sudah tersimpan"; + context.commit("update_msg_success", msg); + context.commit("update_alert_success", true); + context.commit("update_dialog_form", false); + } + } catch (e) { + context.commit("update_error_message", e); + context.commit("update_lookup_expedition", 3); + console.log(e); + } + }, + async editData(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token(); + let resp = await api.edititem(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_error_message", resp.message); + console.log(resp.message); + } else { + context.commit("update_error_message", ""); + context.commit("update_save_status", 2); + let data = resp.data; + context.dispatch("lookup"); + var msg = "Ekspedisi " + prm.name + " berhasil diubah"; + context.commit("update_msg_success", msg); + context.commit("update_alert_success", true); + context.commit("update_dialog_form", false); + } + } catch (e) { + context.commit("update_error_message", e); + context.commit("update_lookup_expedition", 3); + console.log(e); + } + }, + async deleteData(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token(); + let resp = await api.deleteitem(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_error_message", resp.message); + console.log(resp.message); + } else { + context.commit("update_error_message", ""); + context.commit("update_save_status", 2); + let data = resp.data; + context.dispatch("lookup"); + var msg = "Ekspedisi " + prm.name + " berhasil dihapus"; + context.commit("update_msg_success", msg); + context.commit("update_alert_success", true); + context.commit("update_dialog_form", false); + } + } catch (e) { + context.commit("update_error_message", e); + context.commit("update_lookup_expedition", 3); + console.log(e); + } + }, + }, +}; diff --git a/test/vuex/acc-one-md-expedition/store.js b/test/vuex/acc-one-md-expedition/store.js new file mode 100644 index 0000000..0c946b2 --- /dev/null +++ b/test/vuex/acc-one-md-expedition/store.js @@ -0,0 +1,16 @@ +// data ... +// Mutations +// +// +// Actions +import expedition from "./modules/expedition.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + expedition: expedition, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-md-item-category/api/rktype.js b/test/vuex/acc-one-md-item-category/api/rktype.js new file mode 100644 index 0000000..9eb0722 --- /dev/null +++ b/test/vuex/acc-one-md-item-category/api/rktype.js @@ -0,0 +1,99 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getListing(prm) { + try { + var resp = await axios.post(URL + 'mdcategory/listcategory', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function gettype(token, prm) { + try { + var resp = await axios.post(URL + 'mdcategory/gettype', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteCategory(prm) { + try { + var resp = await axios.post(URL + 'mdcategory/deleteCategory', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveCategory(prm) { + try { + var resp = await axios.post(URL + 'mdcategory/addCategory', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function updateCategory(prm) { + try { + var resp = await axios.post(URL + 'mdcategory/editCategory', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-item-category/components/detail.vue b/test/vuex/acc-one-md-item-category/components/detail.vue new file mode 100644 index 0000000..290f728 --- /dev/null +++ b/test/vuex/acc-one-md-item-category/components/detail.vue @@ -0,0 +1,189 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-item-category/components/listing.vue b/test/vuex/acc-one-md-item-category/components/listing.vue new file mode 100644 index 0000000..733b7bb --- /dev/null +++ b/test/vuex/acc-one-md-item-category/components/listing.vue @@ -0,0 +1,164 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-item-category/index.php b/test/vuex/acc-one-md-item-category/index.php new file mode 100644 index 0000000..498e797 --- /dev/null +++ b/test/vuex/acc-one-md-item-category/index.php @@ -0,0 +1,73 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-item-category/modules/rktype.js b/test/vuex/acc-one-md-item-category/modules/rktype.js new file mode 100644 index 0000000..61be5db --- /dev/null +++ b/test/vuex/acc-one-md-item-category/modules/rktype.js @@ -0,0 +1,202 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/rktype.js" + +export default { + namespaced: true, + state: { + typelist: [], + total_listtype: 0, + status_get: 0, + selected_type: {}, + snackbar: false, + message_snack: "", + errors: [], + save_status: 0, + act: "new", + search: "", + categorylist: [], + total_categorylist: 0, + selected_category: {}, + xcategory: "" + }, + mutations: { + update_selected_type(state, data) { + state.selected_type = data + }, + update_total_listtype(state, data) { + state.total_listtype = data + }, + update_typelist(state, data) { + state.typelist = data + }, + update_status_get(state, data) { + state.status_get = data + }, + open_snackbar(state, bool) { + state.snackbar = bool + }, + update_message_snack(state, data) { + state.message_snack = data + }, + update_errors(state, val) { + state.errors = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_act(state, val) { + state.act = val + }, + update_search(state, val) { + state.search = val + }, + update_categorylist(state, val) { + state.categorylist = val + }, + update_total_categorylist(state, val) { + state.total_categorylist = val + }, + update_selected_category(state, val) { + state.selected_category = val + }, + update_xcategory(state, val) { + state.xcategory = val + } + }, + actions: { + async getList(context) { + context.commit("update_status_get", 1); + try { + var prm = {token: one_token(), search: context.state.search}; + let resp = await api.getListing(prm); + if (resp.status != "OK") { + context.commit("update_status_get", 3); + context.commit("update_message_snack", resp.message); + context.commit("open_snackbar", true); + } else { + context.commit("update_status_get", 2); + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_categorylist", data.records); + context.commit("update_total_categorylist", data.total); + } + } catch (error) { + context.commit("update_status_get", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async gettype(context, prm) { + context.commit("update_status_get", 1); + try { + let resp = await api.gettype(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_status_get", 3); + context.commit("update_message_snack", resp.message); + context.commit("open_snackbar", true); + } else { + context.commit("update_status_get", 2); + context.commit("update_message_snack", resp.message); + let data = { + records: resp.data.records + } + + context.commit("update_typelist", data.records) + } + } catch (e) { + context.commit("update_status_get", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async delete(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token(); + let resp = await api.deleteCategory(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("update_save_status", 3); + context.commit("update_message_snack", resp.message); + + context.commit("open_snackbar", true); + var msg = "Berhasil menghapus data kategori"; + context.commit("update_message_snack", msg); + context.commit("update_selected_type", {}); + context.commit("update_xcategory", ""); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_save_status", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async save(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token(); + let resp = await api.saveCategory(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("update_save_status", 2); + context.commit("update_message_snack", resp.message); + + + context.commit("open_snackbar", true); + var msg = "Berhasil menyimpan data kategori"; + context.commit("update_message_snack", msg); + context.commit("update_selected_type", {}); + context.commit("update_xcategory", ""); + context.commit("update_errors", []); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_save_status", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async update(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token() + let resp = await api.updateCategory(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("update_save_status", 2); + context.commit("update_message_snack", resp.message); + + context.commit("open_snackbar", true); + var msg = "Berhasil menyimpan data kategori"; + context.commit("update_message_snack", msg); + context.commit("update_selected_type", {}); + context.commit("update_xcategory", ""); + context.commit("update_errors", []); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_save_status", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + } + } +}; \ No newline at end of file diff --git a/test/vuex/acc-one-md-item-category/store.js b/test/vuex/acc-one-md-item-category/store.js new file mode 100644 index 0000000..a476655 --- /dev/null +++ b/test/vuex/acc-one-md-item-category/store.js @@ -0,0 +1,17 @@ +import rktype from "./modules/rktype.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + rktype: rktype, + system: system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}) \ No newline at end of file diff --git a/test/vuex/acc-one-md-item-regional/api/itemregional.js b/test/vuex/acc-one-md-item-regional/api/itemregional.js new file mode 100644 index 0000000..48950fc --- /dev/null +++ b/test/vuex/acc-one-md-item-regional/api/itemregional.js @@ -0,0 +1,175 @@ +const URL = "/one-api/mockup/masterdata/accounting/itemregional"; + + + + +export async function getItem(prm) { + try { + var resp = await axios.post(URL + '/getItem', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + '/getRegional', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUnit(prm) { + try { + var resp = await axios.post(URL + '/getUnit', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getDepartment(prm) { + try { + var resp = await axios.post(URL + '/getDepartment', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search(prm) { + try { + var resp = await axios.post(URL + "/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function addData(prm) { + try { + var resp = await axios.post(URL + '/addData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getByID(prm) { + try { + var resp = await axios.post(URL + '/get_by_id', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editData(prm) { + try { + var resp = await axios.post(URL + '/editData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteData(prm) { + try { + var resp = await axios.post(URL + '/deleteData', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-md-item-regional/components/ItemRegional.vue b/test/vuex/acc-one-md-item-regional/components/ItemRegional.vue new file mode 100644 index 0000000..13664c7 --- /dev/null +++ b/test/vuex/acc-one-md-item-regional/components/ItemRegional.vue @@ -0,0 +1,900 @@ + + + + + diff --git a/test/vuex/acc-one-md-item-regional/index.php b/test/vuex/acc-one-md-item-regional/index.php new file mode 100644 index 0000000..4c303d5 --- /dev/null +++ b/test/vuex/acc-one-md-item-regional/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-item-regional/modules/itemregional.js b/test/vuex/acc-one-md-item-regional/modules/itemregional.js new file mode 100644 index 0000000..25ab7cd --- /dev/null +++ b/test/vuex/acc-one-md-item-regional/modules/itemregional.js @@ -0,0 +1,626 @@ +import * as api from "../api/itemregional.js" + +export default { + namespaced: true, + state: { + Fa_ClassID: 0, + a_coas: [], + a_msg_info: '', + a_open_dialog_info: false, + a_save_status: 0, + // search table + a_x_search: '', + a_current_page: 1, + a_last_id: -1, + a_total_coa: 0, + // search table + a_selected_a_coa: {}, + a_search_status: 0, + a_alert_success: false, + a_msg_success: '', + a_alert_error: false, + a_save_error_message: '', + dialog_add_coa: false, + dialog_edit_coa: false, + e_loading_nat_group: false, + // text classname + a_faname: '', + e_classname: '', + // ac coa + a_loading_coa: false, + a_coa_list: [], + a_coa: {}, + a_coa_search: '', + + // ac item + a_loading_item: false, + a_item_list: [], + a_item: {}, + a_item_search: '', + + // ac regional + a_loading_regional: false, + a_regional_list: [], + a_regional: {}, + a_regional_search: '', + + // ac unit + a_loading_unit: false, + a_unit_list: [], + a_unit: {}, + a_unit_search: '', + + // ac department + a_loading_department: false, + a_department_list: [], + a_department: {}, + a_department_search: '', + a_inventaris : '', + a_note : '', + a_fa_account_id: 0, + a_fa_account_name: '', + a_accum_depre_account_id: 0, + a_accum_depre_account_name: '', + a_depre_account_id: 0, + a_depre_account_name: '', + a_qty: 0, + a_acquisition_price: 0, + + + // text note + a_note: '', + e_note: '', + a_errors_save: [], + Fa_ClassID: 0, + a_errors_save_coa: [], + xid: 0, + xnumber: '', + errors: [] + }, + mutations: { + update_errors(state, val) { + state.errors = val; + }, + update_xid(state, val) { + state.xid = val + }, + update_xnumber(state, val) { + state.xnumber = val + }, + update_a_errors_save_coa(state, val) { + state.a_errors_save_coa = val + }, + update_a_selected_a_coa(state, val) { + state.a_selected_a_coa = val + }, + update_e_loading_nat_group(state, val) { + state.e_loading_nat_group = val + }, + update_a_errors_save(state, val) { + state.a_errors_save = val + }, + update_a_save_error_message(state, val) { + state.a_save_error_message = val + }, + update_a_alert_error(state, val) { + state.a_alert_error = val + }, + update_a_msg_success(state, val) { + state.a_msg_success = val + }, + update_a_msg_info(state, val) { + state.a_msg_info = val + }, + update_a_open_dialog_info(state, val) { + state.a_open_dialog_info = val + }, + update_a_alert_success(state, val) { + state.a_alert_success = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + //table + update_a_search_error_message(state, val) { + state.a_search_error_message = val + }, + update_a_search_status(state, val) { + state.a_search_status = val + }, + update_a_x_search(state, val) { + state.a_x_search = val + }, + update_a_current_page(state, val) { + state.a_current_page = val + }, + update_a_last_id(state, val) { + state.a_last_id = val + }, + update_a_total_coa(state, val) { + state.a_total_coa = val + }, + update_a_a_coas(state, val) { + state.a_coas = val + }, + // text classname + update_a_faname(state, val) { + state.a_faname = val + }, + update_e_classname(state, val) { + state.e_classname = val + }, + // ac coa + update_a_loading_coa(state, val) { + state.a_loading_coa = val + }, + update_e_loading_coa(state, val) { + state.e_loading_coa = val + }, + update_a_coa_list(state, val) { + state.a_coa_list = val + }, + update_e_coa_list(state, val) { + state.e_coa_list = val + }, + update_a_coa(state, val) { + state.a_coa = val + }, + update_e_coa(state, val) { + state.e_coa = val + }, + update_a_coa_search(state, val) { + state.a_coa_search = val + }, + update_e_coa_search(state, val) { + state.e_coa_search = val + }, + // ac item + update_a_loading_item(state, val) { + state.a_loading_item = val + }, + update_a_item_list(state, val) { + state.a_item_list = val + }, + update_a_item(state, val) { + state.a_item = val + }, + update_a_item_search(state, val) { + state.a_item_search = val + }, + // ac regional + update_a_loading_regional(state, val) { + state.a_regional_item = val + }, + update_a_regional_list(state, val) { + state.a_regional_list = val + }, + update_a_regional(state, val) { + state.a_regional = val + }, + update_a_regional_search(state, val) { + state.a_regional_search = val + }, + // ac unit + update_a_loading_unit(state, val) { + state.a_loading_unit = val + }, + update_a_unit_list(state, val) { + state.a_unit_list = val + }, + update_a_unit(state, val) { + state.a_unit = val + }, + update_a_unit_search(state, val) { + state.a_unit_search = val + }, + // ac department + update_a_loading_department(state, val) { + state.a_loading_department = val + }, + update_a_department_list(state, val) { + state.a_department_list = val + }, + update_a_department(state, val) { + state.a_department = val + }, + update_a_department_search(state, val) { + state.a_department_search = val + }, + update_a_inventaris(state, val) { + state.a_inventaris = val + }, + update_a_note(state, val) { + state.a_note = val + }, + update_a_fa_account_id(state, val) { + state.a_fa_account_id = val + }, + update_a_fa_account_name(state, val) { + state.a_fa_account_name = val + }, + update_a_accum_depre_account_id(state, val) { + state.a_accum_depre_account_id = val + }, + update_a_accum_depre_account_name(state, val) { + state.a_accum_depre_account_name = val + }, + update_a_depre_account_id(state, val) { + state.a_depre_account_id = val + }, + update_a_depre_account_name(state, val) { + state.a_depre_account_name = val + }, + update_a_qty(state, val) { + state.a_qty = val + }, + update_a_acquisition_price(state, val) { + state.a_acquisition_price = val + }, + // text note + update_a_note(state, val) { + state.a_note = val + }, + update_e_note(state, val) { + state.e_note = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + update_dialog_edit_coa(state, val) { + state.dialog_edit_coa = val + }, + update_Fa_ClassID(state, val) { + state.Fa_ClassID = val + }, + update_a_save_status(state, val) { + state.a_save_status = val + }, + }, + actions: { + // search + async search(context, prm) { + context.commit("update_a_search_status", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", resp.message) + context.commit("update_a_msg_info", resp.message) + context.commit("update_a_open_dialog_info", true) + } else { + context.commit("update_a_search_status", 2) + context.commit("update_a_search_error_message", "") + context.commit("update_a_msg_info", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_a_a_coas", data.records) + context.commit("update_a_total_coa", data.total) + } + } catch (e) { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", e.message) + context.commit("update_a_msg_info", e.message) + context.commit("update_a_open_dialog_info", true) + } + }, + + + + async open_add_item(context, payload) { + context.commit("update_a_loading_item", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getItem(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_item", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_item", false) + context.commit("update_a_item_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_item", false) + } + }, + + async open_add_regional(context, payload) { + context.commit("update_a_loading_regional", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getRegional(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_regional", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_regional", false) + context.commit("update_a_regional_list", resp.data) + console.log('regional') + console.log(resp.data) + } + } catch (e) { + context.commit("update_a_loading_regional", false) + } + }, + async open_add_unit(context, payload) { + context.commit("update_a_loading_unit", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getUnit(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_unit", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_unit", false) + context.commit("update_a_unit_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_unit", false) + } + }, + async open_add_department(context, payload) { + context.commit("update_a_loading_department", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getDepartment(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_department", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_department", false) + context.commit("update_a_department_list", resp.data) + } + } catch (e) { + context.commit("update_a_loading_department", false) + } + }, + // add data + async add_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + + let resp = await api.addData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Add Data Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_add_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + + context.commit("itemregional/update_dialog_add_coa", false); + context.commit("itemregional/update_a_faname", ""); + context.commit("itemregional/update_a_coa", {}); + context.commit("itemregional/update_a_deprecorp", ""); + context.commit("itemregional/update_a_coa_accum_depre", {}); + context.commit("itemregional/update_a_note", ""); + } else { + context.commit("update_a_errors_save", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + + // get_by_id + async get_by_id(context, payload) { + context.commit("update_e_loading_nat_group", true) + try { + let prm = {}; + prm.token = one_token() + // fa_class + prm.Fa_ClassID = payload.Fa_ClassID + // coa + prm.Fa_ClassCoaID = payload.Fa_ClassCoaID + // accum depre + prm.Fa_ClassAccumDepreCoaID = payload.Fa_ClassAccumDepreCoaID + + let resp = await api.getByID(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_nat_group", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_nat_group", true) + + // MapNatGroup_ID + context.commit("update_Fa_ClassID", resp.data.record_fa_class[0].Fa_ClassID) + + // coa + context.commit("update_e_coa_list", resp.data.records_coa) + context.commit("update_e_coa", { + coaID: resp.data.records_coa[0].coaID, + coaAccountNo: resp.data.records_coa[0].coaAccountNo, + coaDescription: resp.data.records_coa[0].coaDescription, + coaSubDescription: resp.data.records_coa[0].coaSubDescription, + coaAccountType: resp.data.records_coa[0].coaAccountType, + coaSpecialAccountType: resp.data.records_coa[0].coaSpecialAccountType, + coaIsInput: resp.data.records_coa[0].coaIsInput, + coaReportSchedule: resp.data.records_coa[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_coa[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_coa[0].coaCashFlowCategory, + coaCreated: resp.data.records_coa[0].coaCreated, + coaLastUpdated: resp.data.records_coa[0].coaLastUpdated, + coaIsActive: resp.data.records_coa[0].coaIsActive, + coaLevel: resp.data.records_coa[0].coaLevel + }) + + // accum depre + context.commit("update_e_coa_accum_depre_list", resp.data.records_accum_depre) + context.commit("update_e_coa_accum_depre", { + coaID: resp.data.records_accum_depre[0].coaID, + coaAccountNo: resp.data.records_accum_depre[0].coaAccountNo, + coaDescription: resp.data.records_accum_depre[0].coaDescription, + coaSubDescription: resp.data.records_accum_depre[0].coaSubDescription, + coaAccountType: resp.data.records_accum_depre[0].coaAccountType, + coaSpecialAccountType: resp.data.records_accum_depre[0].coaSpecialAccountType, + coaIsInput: resp.data.records_accum_depre[0].coaIsInput, + coaReportSchedule: resp.data.records_accum_depre[0].coaReportSchedule, + coaCurrencyCode: resp.data.records_accum_depre[0].coaCurrencyCode, + coaCashFlowCategory: resp.data.records_accum_depre[0].coaCashFlowCategory, + coaCreated: resp.data.records_accum_depre[0].coaCreated, + coaLastUpdated: resp.data.records_accum_depre[0].coaLastUpdated, + coaIsActive: resp.data.records_accum_depre[0].coaIsActive, + coaLevel: resp.data.records_accum_depre[0].coaLevel + }) + + // fa classname + context.commit("update_e_classname", resp.data.record_fa_class[0].Fa_ClassName) + + // note + context.commit("update_e_note", resp.data.record_fa_class[0].Fa_ClassAccumNote) + + // depre corp + context.commit("update_e_deprecorp", resp.data.record_fa_class[0].Fa_ClassDepreCorp) + + context.commit("update_dialog_edit_coa", true) + } + } catch (e) { + context.commit("update_e_loading_nat_group", false) + } + }, + + // get ac coa from api + async open_edit_coa(context, payload) { + context.commit("update_e_loading_coa", true) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.getAcCoa(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_e_loading_coa", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_e_loading_coa", false) + context.commit("update_e_coa_list", resp.data) + } + } catch (e) { + context.commit("update_e_loading_coa", false) + } + }, + + + + // edit data + async edit_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + + let resp = await api.editData(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Edit Data Sukses" + context.commit("update_a_msg_success", msg) + context.commit('update_dialog_add_coa', false) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + + context.commit("itemregional/update_dialog_add_coa", false); + context.commit("itemregional/update_a_faname", ""); + context.commit("itemregional/update_a_coa", {}); + context.commit("itemregional/update_a_deprecorp", ""); + context.commit("itemregional/update_a_coa_accum_depre", {}); + context.commit("itemregional/update_a_note", ""); + } else { + context.commit("update_a_errors_save", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + // delete data + async delete_data(context, prm) { + context.commit("update_a_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteData(prm) + if (resp.status != "OK") { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", resp.message) + context.commit("update_a_alert_error", true) + } else { + context.commit("update_a_save_status", 2) + context.commit("update_a_save_error_message", resp.message) + let data = { + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_a_alert_success", true) + var msg = " Coa " + prm.delete_data + " berhasil dihapus" + context.commit("update_a_msg_success", msg) + context.dispatch("search", { + current_page: context.state.a_current_page, + search: context.state.a_x_search, + last_id: -1 + }) + } else { + context.commit("update_a_errors_save_coa", []) + } + + } + } catch (e) { + context.commit("update_a_save_status", 3) + context.commit("update_a_save_error_message", e.message) + context.commit("update_a_alert_error", true) + } + }, + }, +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-item-regional/store.js b/test/vuex/acc-one-md-item-regional/store.js new file mode 100644 index 0000000..069170d --- /dev/null +++ b/test/vuex/acc-one-md-item-regional/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import itemregional from "./modules/itemregional.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + itemregional:itemregional, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-md-itemdivision/api/a_itemdiv.js b/test/vuex/acc-one-md-itemdivision/api/a_itemdiv.js new file mode 100644 index 0000000..558f876 --- /dev/null +++ b/test/vuex/acc-one-md-itemdivision/api/a_itemdiv.js @@ -0,0 +1,80 @@ +const URL = "/one-api/itemdivision/Itemdivision"; + +export async function getDropdownCategory(prm) { + try { + var resp = await axios.post(URL + '/dropdown_item_category', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchItem(prm) { + try { + var resp = await axios.post(URL + "/search_item", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function itemDivisionList(prm) { + try { + var resp = await axios.post(URL + "/item_division_list", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateItemDivision(prm) { + try { + var resp = await axios.post(URL + "/update_item_division", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-itemdivision/components/itemdivList.vue b/test/vuex/acc-one-md-itemdivision/components/itemdivList.vue new file mode 100644 index 0000000..1370e73 --- /dev/null +++ b/test/vuex/acc-one-md-itemdivision/components/itemdivList.vue @@ -0,0 +1,529 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-itemdivision/modules/a_itemdiv.js b/test/vuex/acc-one-md-itemdivision/modules/a_itemdiv.js new file mode 100644 index 0000000..9f69306 --- /dev/null +++ b/test/vuex/acc-one-md-itemdivision/modules/a_itemdiv.js @@ -0,0 +1,313 @@ +import * as api from "../api/a_itemdiv.js" + +export default { + namespaced: true, + state: { + a_errors_save_coa: [], + selected_item: {}, + items: [], + a_save_status: 0, + a_save_error_message: '', + a_msg_success: '', + a_msg_info: '', + a_open_dialog_info: false, + a_alert_error: false, + a_alert_success: false, + // search table + a_x_search: '', + a_current_page: 1, + a_last_id: -1, + total_item: 0, + // search table + + // dropdown category + selected_category: {}, + categorys: [], + + // array item division + item_division_arr: [], + + // item division selected + selected_itemdivision: {}, + // list item division + itemdivisions: [], + + // state dialog + msg_gagal: "", + dialog_gagal: false, + msg_success: "", + dialog_success: false, + }, + mutations: { + update_msg_success(state, val) { + state.msg_success = val; + }, + update_dialog_success(state, val) { + state.dialog_success = val; + }, + update_msg_gagal(state, val) { + state.msg_gagal = val; + }, + update_dialog_gagal(state, val) { + state.dialog_gagal = val; + }, + update_a_errors_save_coa(state, val) { + state.a_errors_save_coa = val + }, + update_a_search_error_message(state, val) { + state.a_search_error_message = val + }, + update_a_search_status(state, val) { + state.a_search_status = val + }, + update_a_search_statusr(state, val) { + state.a_search_statusr = val + }, + update_selected_item(state, val) { + state.selected_item = val + }, + update_items(state, val) { + state.items = val + }, + update_a_open_dialog_info(state, val) { + state.a_open_dialog_info = val + }, + update_a_msg_info(state, val) { + state.a_msg_info = val + }, + update_a_x_search(state, val) { + state.a_x_search = val + }, + update_a_current_page(state, val) { + state.a_current_page = val + }, + update_a_last_id(state, val) { + state.a_last_id = val + }, + update_total_item(state, val) { + state.total_item = val + }, + update_a_msg_success(state, val) { + state.a_msg_success = val + }, + update_a_save_status(state, val) { + state.a_save_status = val + }, + update_a_save_error_message(state, val) { + state.a_save_error_message = val + }, + update_a_alert_success(state, val) { + state.a_alert_success = val + }, + update_a_alert_error(state, val) { + state.a_alert_error = val + }, + update_dialog_add_coa(state, val) { + state.dialog_add_coa = val + }, + update_dialog_edit_coa(state, val) { + state.dialog_edit_coa = val + }, + update_a_loading_category(state, val) { + state.a_loading_nat_group = val + }, + update_e_loading_nat_group(state, val) { + state.e_loading_nat_group = val + }, + update_a_nat_group(state, val) { + state.a_nat_group = val + }, + update_e_nat_group(state, val) { + state.e_nat_group = val + }, + update_a_nat_group_list(state, val) { + state.a_nat_group_list = val + }, + update_e_nat_group_list(state, val) { + state.e_nat_group_list = val + }, + + // dropdown category + update_selected_category(state, val) { + state.selected_category = val + }, + + update_categorys(state, val) { + state.categorys = val + }, + + // array item division + update_item_division_arr(state, val) { + state.item_division_arr = val + }, + + // item division selected + update_selected_itemdivision(state, val) { + state.selected_itemdivision = val + }, + + update_itemdivisions(state, val) { + state.itemdivisions = val + }, + + // update item division arr + update_itemdivision_arr(state, val) { + const idx = state.itemdivisions.findIndex( + item => item.M_ItemDivisionID === val.M_ItemDivisionID + ); + + if (idx !== -1) { + state.itemdivisions[idx].IsChecked = val.IsChecked; + } + + const arrIndex = state.item_division_arr.findIndex( + item => item.M_ItemDivisionID === val.M_ItemDivisionID + ); + + if (arrIndex !== -1) { + state.item_division_arr.splice(arrIndex, 1); + state.item_division_arr.push(val); + } else { + if (val.IsChecked === "1") { + state.item_division_arr.push(val); + } else { + state.item_division_arr.push(val); + } + } + }, + }, + actions: { + // get category from api + async getDropdownCategoryA(context) { + context.commit("update_a_loading_category", true) + try { + let prm = {}; + prm.token = one_token() + let resp = await api.getDropdownCategory(prm) + // console.log('data nat_group ',resp) + if (resp.status != "OK") { + context.commit("update_a_loading_category", false) + } else { + // console.log('data nat_group ',resp.data) + context.commit("update_a_loading_category", false) + context.commit("update_categorys", resp.data.records) + // context.commit("update_selected_category", resp.data.records[0]) + } + } catch (e) { + context.commit("update_a_loading_category", false) + } + }, + + // searchItem + async searchItemA(context, prm) { + context.commit("update_a_search_status", 1) + try { + prm.token = one_token() + let resp = await api.searchItem(prm) + if (resp.status != "OK") { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", resp.message) + context.commit("update_a_msg_info", resp.message) + context.commit("update_a_open_dialog_info", true) + } else { + context.commit("update_a_search_status", 2) + context.commit("update_a_search_error_message", "") + context.commit("update_a_msg_info", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_items", data.records) + context.commit("update_total_item", data.total) + } + } catch (e) { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", e.message) + context.commit("update_a_msg_info", e.message) + context.commit("update_a_open_dialog_info", true) + } + }, + + // item division list by item selected + async itemDivisionListA(context, prm) { + context.commit("update_a_search_status", 1) + try { + // prm.token = one_token() + var prm = { + current_page: context.state.current_pager, + M_ItemID: context.state.selected_item.M_ItemID, + last_id: -1, + current_page: -1, + token: one_token() + }; + + let resp = await api.itemDivisionList(prm) + if (resp.status != "OK") { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", resp.message) + context.commit("update_a_msg_info", resp.message) + context.commit("update_a_open_dialog_info", true) + } else { + context.commit("update_a_search_status", 2) + context.commit("update_a_search_error_message", "") + context.commit("update_a_msg_info", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_itemdivisions", data.records) + // context.commit("update_total_item", data.total) + } + } catch (e) { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", e.message) + context.commit("update_a_msg_info", e.message) + context.commit("update_a_open_dialog_info", true) + } + }, + + // update item division + async updateItemDivisionA(context, prm) { + context.commit("update_a_search_status", 1) + try { + var prm = { + M_ItemID: context.state.selected_item.M_ItemID, + M_ItemDivisionID: context.state.item_division_arr, + last_id: -1, + current_page: -1, + token: one_token() + }; + + let resp = await api.updateItemDivision(prm) + if (resp.status != "OK") { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", resp.message) + context.commit("update_a_msg_info", resp.message) + context.commit("update_a_open_dialog_info", true) + } else { + context.commit("update_a_search_status", 2) + context.commit("update_a_search_error_message", "") + context.commit("update_a_msg_info", resp.message) + + context.commit("update_dialog_success", true); + var msg = "Update Sukses"; + context.commit("update_msg_success", msg); + + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_itemdivisions", data.records) + } + } catch (e) { + context.commit("update_a_search_status", 3) + context.commit("update_a_search_error_message", e.message) + context.commit("update_a_msg_info", e.message) + context.commit("update_a_open_dialog_info", true) + } + }, + }, +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-itemdivision/store.js b/test/vuex/acc-one-md-itemdivision/store.js new file mode 100644 index 0000000..82dab79 --- /dev/null +++ b/test/vuex/acc-one-md-itemdivision/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import a_itemdiv from "./modules/a_itemdiv.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + a_itemdiv:a_itemdiv, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-md-itemunit/api/unit.js b/test/vuex/acc-one-md-itemunit/api/unit.js new file mode 100644 index 0000000..ec7f6fa --- /dev/null +++ b/test/vuex/acc-one-md-itemunit/api/unit.js @@ -0,0 +1,80 @@ +// const URL = "/one-api/v1/masterdata/"; +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function lookupbyname(prm) { + try { + var resp = await axios.post(URL + 'itemunit/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function add(prm) { + try { + var resp = await axios.post(URL + 'itemunit/add', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(token,id) { + try { + var resp = await axios.post(URL + 'itemunit/delete', + { id: id, token:token }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +// edit +export async function edit(prm) { + try { + var resp = await axios.post(URL + 'itemunit/edit', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-itemunit/components/oneMdItemUnit.vue b/test/vuex/acc-one-md-itemunit/components/oneMdItemUnit.vue new file mode 100644 index 0000000..640909c --- /dev/null +++ b/test/vuex/acc-one-md-itemunit/components/oneMdItemUnit.vue @@ -0,0 +1,539 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-itemunit/index.php b/test/vuex/acc-one-md-itemunit/index.php new file mode 100644 index 0000000..c672045 --- /dev/null +++ b/test/vuex/acc-one-md-itemunit/index.php @@ -0,0 +1,70 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/acc-one-md-itemunit/modules/unit.js b/test/vuex/acc-one-md-itemunit/modules/unit.js new file mode 100644 index 0000000..d578be9 --- /dev/null +++ b/test/vuex/acc-one-md-itemunit/modules/unit.js @@ -0,0 +1,254 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/unit.js" + +export default { + namespaced: true, + state: { + lookup_error_message:'', + lookup_unit:0, + units:[], + total_units:0, + total_filter_units:0, + current_page:1, + x_search: '', + autocomplete_status: 0, + pagination:{ + descending:'asc', + sortBy:'ItemUnitCode' + }, + search_status: false, + + dialog_form_unit: false, + alert_success: false, + msg_success: "", + show_all: 'N', + errors: [], + act: 'new', + + selected_unit: { + name: "" + }, + save_status: 0, + save_error_message: '', + }, + mutations: { + update_lookup_error_message(state, status) { + state.lookup_error_message = status + }, + update_lookup_unit(state, status) { + state.lookup_unit = status + }, + + update_units(state, data) { + state.units = data.records + state.total_units = data.total + state.total_filter_units = data.total_filter + }, + + update_current_page(state, val) { + state.current_page = val + }, + + update_autocomplete_status(state, val) { + state.autocomplete_status = val + }, + + update_last_id(state, val) { + state.last_id = val + }, + + update_pagination(state, val) { + state.pagination = val + }, + + update_dialog_form_unit(state, val) { + console.log(state, val); + state.dialog_form_unit = val + }, + + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + + update_errors(state, val) { + state.errors = val + }, + + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + + update_act(state, val) { + state.act = val + }, + + update_search_status(state, val) { + state.search_status = val + }, + + update_selected_unit(state, val) { + state.selected_unit = val + }, + + update_x_search(state, val) { + state.x_search = val + state.current_page = 1; + }, + }, + actions: { + // load data dan search + async lookupbyname(context, prm) { + context.commit("update_lookup_unit", 1) + context.commit("update_search_status", true) + try { + // prm.token = one_token() + var prm = { + // query:context.state.xsearch, + current_page:context.state.current_page, + // last_id:context.state.last_id, + search:context.state.x_search, + sortBy:context.state.pagination.sortBy, + sortStatus:context.state.pagination.descending, + token:one_token() + } + let resp = await api.lookupbyname(prm) + if (resp.status != "OK") { + context.commit("update_search_status", false) + context.commit("update_lookup_unit", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_search_status", false) + context.commit("update_lookup_unit", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total, + total_filter: resp.data.total_filter + } + context.commit("update_units", data) + if(context.state.last_id != -1){ + var alldatas = resp.data.records + // var selected = _.find(alldatas, function(o) { return o.id === context.state.last_id }) + var selected = _.find(alldatas, function (o) { + return o.id === context.state.last_id; + }); + context.commit("update_selected_unit", selected) + } + + } + } catch (e) { + context.commit("update_search_status", false) + context.commit("update_lookup_unit", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + + // add data + async add(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.add(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_save_error_message", resp.message) + var data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form_unit", false) + var msg =" Item Unit " + prm.name + " sudah tersimpan dong ..." + context.commit("update_msg_success", msg) + context.dispatch("lookupbyname") + } else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + + // hapus + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + let resp = await api.xdelete(one_token(), prm.id) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_success", true) + + var msg = " Item Unit " + prm.name + " sudah dihapus dong" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + // context.commit("update_selected_unit", {}) + context.dispatch("lookupbyname") + } + } catch (e) { + context.commit("update_save_status", 3) + console.log(e) + } + }, + + // edit + async edit(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.edit(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_save_error_message", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_form_unit", false) + var msg = " Item Unit " + prm.name + " sudah terupdate dong ..." + context.commit("update_msg_success", msg) + context.dispatch("lookupbyname") + }else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-itemunit/store.js b/test/vuex/acc-one-md-itemunit/store.js new file mode 100644 index 0000000..b1a3cba --- /dev/null +++ b/test/vuex/acc-one-md-itemunit/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import unit from "./modules/unit.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + unit:unit, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-md-periode/api/api-periode.js b/test/vuex/acc-one-md-periode/api/api-periode.js new file mode 100644 index 0000000..12c0252 --- /dev/null +++ b/test/vuex/acc-one-md-periode/api/api-periode.js @@ -0,0 +1,77 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getListing(params) { + try { + var resp = await axios.post(URL + 'mdperiode/listperiode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function p_delete(params) { + try { + var resp = await axios.post(URL + 'mdperiode/deleteperiode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function p_add(params) { + try { + var resp = await axios.post(URL + 'mdperiode/addperiode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function p_edit(params) { + try { + var resp = await axios.post(URL + 'mdperiode/editperiode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-periode/api/coa.js b/test/vuex/acc-one-md-periode/api/coa.js new file mode 100644 index 0000000..5284a0f --- /dev/null +++ b/test/vuex/acc-one-md-periode/api/coa.js @@ -0,0 +1,77 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/addnewcoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function update(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/editcoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(token,coid) { + try { + var resp = await axios.post(URL + 'mdcoa/deletecoa', { coid: coid, token:token }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-periode/components/detail.vue b/test/vuex/acc-one-md-periode/components/detail.vue new file mode 100644 index 0000000..b1d39d6 --- /dev/null +++ b/test/vuex/acc-one-md-periode/components/detail.vue @@ -0,0 +1,187 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-periode/components/listing.vue b/test/vuex/acc-one-md-periode/components/listing.vue new file mode 100644 index 0000000..222ecde --- /dev/null +++ b/test/vuex/acc-one-md-periode/components/listing.vue @@ -0,0 +1,125 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-periode/index.php b/test/vuex/acc-one-md-periode/index.php new file mode 100644 index 0000000..20b0451 --- /dev/null +++ b/test/vuex/acc-one-md-periode/index.php @@ -0,0 +1,68 @@ + + + + + + + + + + One + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-periode/modules/coa.js b/test/vuex/acc-one-md-periode/modules/coa.js new file mode 100644 index 0000000..87af723 --- /dev/null +++ b/test/vuex/acc-one-md-periode/modules/coa.js @@ -0,0 +1,213 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/coa.js" + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: 'new', + save_status: 0, + save_error_message: '', + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_x_search(state, val) { + state.x_search = val + state.current_page = 1 + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_coas(state, val) { + state.coas = val + }, + update_total_coas(state, val) { + state.total_coas = val + }, + update_selected_coa(state, val) { + state.selected_coa = val + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_errors(state, val) { + state.errors = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_dialog_error(state, val) { + state.dialog_error = val + }, + }, + actions: { + async search(context) { + context.commit("update_search_status", 1) + try { + var prm = { + token: one_token(), + current_page: context.state.current_page, + search: context.state.x_search, + last_id: -1 + } + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_coas", data.records) + context.commit("update_total_coas", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async save(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + var data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form_coa", false) + var msg =" Account " + prm.description + " sudah tersimpan dong ..." + context.commit("update_msg_success", msg) + context.dispatch("search") + } else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + console.log(e) + } + }, + async update(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.update(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_form_coa", false) + var msg = " Account " + prm.description + " sudah terupdate dong ..." + context.commit("update_msg_success", msg) + context.dispatch("search") + }else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + console.log(e) + } + }, + + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + let resp = await api.xdelete(one_token(), prm.coid) + console.log(prm.coid) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_success", true) + + var msg = " Account " + prm.description + " sudah dihapus dong" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.commit("update_selected_coa", {}) + context.dispatch("search") + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + console.log(e) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-periode/modules/periode.js b/test/vuex/acc-one-md-periode/modules/periode.js new file mode 100644 index 0000000..d9255d7 --- /dev/null +++ b/test/vuex/acc-one-md-periode/modules/periode.js @@ -0,0 +1,160 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/api-periode.js" + +export default { + namespaced: true, + state: { + periode: [], + total_list: 0, + status_get: 0, + selected: {}, + snackbar: false, + message_snack: "" + }, + mutations: { + update_selected(state, data) { + state.selected = data + }, + update_total_list(state, data) { + state.total_list = data + }, + update_list(state, data) { + state.periode = data + }, + update_status_get(state, data) { + state.status_get = data + }, + open_snackbar(state, bool) { + state.snackbar = bool + }, + update_message_snack(state, data) { + state.message_snack = data + } + }, + actions: { + async getList(context) { + context.commit("update_status_get", 1); + try { + var params = {token: one_token()}; + let resp = await api.getListing(params); + if (resp.status != "OK") { + context.commit("update_status_get", 3); + context.commit("update_message_snack", resp.message); + context.commit("open_snackbar", true); + } else { + context.commit("update_status_get", 2); + let data = { + records: resp.data.records, + total: resp.data.total + } + // console.log(data.total); + // console.log(data.records); + context.commit("update_list", data.records); + context.commit("update_total_list", data.total); + } + } catch (error) { + context.commit("update_status_get", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async deletePeriode(context) { + try { + var params = { + token: one_token(), + id: context.state.selected.periodeID + } + console.log(params); + let resp = await api.p_delete(params); + if (resp.status != "OK") { + // console.log(resp.message); + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("open_snackbar", true); + var msg = "Berhasil menghapus data periode"; + context.commit("update_message_snack", msg); + context.commit("update_selected", {}); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async addPeriode(context) { + try { + var params = { + token: one_token(), + ...context.state.selected + }; + console.log(params); + let resp = await api.p_add(params); + if (resp.status != "OK") { + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("open_snackbar", true); + var msg = "Berhasil menyimpan data periode"; + context.commit("update_message_snack", msg); + context.commit("update_selected", {}); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async editPeriode(context) { + try { + var params = { + token: one_token(), + ...context.state.selected + }; + console.log(params); + let resp = await api.p_edit(params); + if (resp.status != "OK") { + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("open_snackbar", true); + var msg = "Berhasil menyimpan data periode"; + context.commit("update_message_snack", msg); + context.commit("update_selected", {}); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async checkNewOrEdit(context) { + if (!checkIsEmpty(context.state.selected)) { + var msg = "Form masih ada yang kosong"; + context.commit("update_message_snack", msg); + context.commit("open_snackbar", true); + return; + } + + if (!context.state.selected.periodeID) { + context.dispatch("addPeriode"); + } else { + context.dispatch("editPeriode"); + } + } + } +}; + +function checkIsEmpty(obj) { + if (Object.keys(obj).length === 0) { + return false; + } + + return obj.periodeYear && obj.periodeMonth && obj.periodeName && obj.periodeStartDate && obj.periodeEndDate; +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-periode/store.js b/test/vuex/acc-one-md-periode/store.js new file mode 100644 index 0000000..fd0f867 --- /dev/null +++ b/test/vuex/acc-one-md-periode/store.js @@ -0,0 +1,17 @@ +import periode from "./modules/periode.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + periode: periode, + system: system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}) \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/api/api-periode.js b/test/vuex/acc-one-md-rk-type/api/api-periode.js new file mode 100644 index 0000000..12c0252 --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/api/api-periode.js @@ -0,0 +1,77 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getListing(params) { + try { + var resp = await axios.post(URL + 'mdperiode/listperiode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function p_delete(params) { + try { + var resp = await axios.post(URL + 'mdperiode/deleteperiode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function p_add(params) { + try { + var resp = await axios.post(URL + 'mdperiode/addperiode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function p_edit(params) { + try { + var resp = await axios.post(URL + 'mdperiode/editperiode', params); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/api/coa.js b/test/vuex/acc-one-md-rk-type/api/coa.js new file mode 100644 index 0000000..5284a0f --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/api/coa.js @@ -0,0 +1,77 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/addnewcoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function update(prm) { + try { + var resp = await axios.post(URL + 'mdcoa/editcoa', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(token,coid) { + try { + var resp = await axios.post(URL + 'mdcoa/deletecoa', { coid: coid, token:token }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/api/rktype.js b/test/vuex/acc-one-md-rk-type/api/rktype.js new file mode 100644 index 0000000..a054d1c --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/api/rktype.js @@ -0,0 +1,77 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getListing(prm) { + try { + var resp = await axios.post(URL + 'mdtype/listtype', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function deleteRkType(prm) { + try { + var resp = await axios.post(URL + 'mdtype/deleteType', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveRkType(prm) { + try { + var resp = await axios.post(URL + 'mdtype/addType', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function updateRkType(prm) { + try { + var resp = await axios.post(URL + 'mdtype/editType', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: error.message + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/components/detail.vue b/test/vuex/acc-one-md-rk-type/components/detail.vue new file mode 100644 index 0000000..f38e327 --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/components/detail.vue @@ -0,0 +1,154 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/components/listing.vue b/test/vuex/acc-one-md-rk-type/components/listing.vue new file mode 100644 index 0000000..9657de9 --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/components/listing.vue @@ -0,0 +1,133 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/index.php b/test/vuex/acc-one-md-rk-type/index.php new file mode 100644 index 0000000..498e797 --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/index.php @@ -0,0 +1,73 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/modules/coa.js b/test/vuex/acc-one-md-rk-type/modules/coa.js new file mode 100644 index 0000000..87af723 --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/modules/coa.js @@ -0,0 +1,213 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/coa.js" + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: 'new', + save_status: 0, + save_error_message: '', + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_x_search(state, val) { + state.x_search = val + state.current_page = 1 + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_coas(state, val) { + state.coas = val + }, + update_total_coas(state, val) { + state.total_coas = val + }, + update_selected_coa(state, val) { + state.selected_coa = val + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_errors(state, val) { + state.errors = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_dialog_error(state, val) { + state.dialog_error = val + }, + }, + actions: { + async search(context) { + context.commit("update_search_status", 1) + try { + var prm = { + token: one_token(), + current_page: context.state.current_page, + search: context.state.x_search, + last_id: -1 + } + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + + context.commit("update_coas", data.records) + context.commit("update_total_coas", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async save(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + var data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form_coa", false) + var msg =" Account " + prm.description + " sudah tersimpan dong ..." + context.commit("update_msg_success", msg) + context.dispatch("search") + } else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + console.log(e) + } + }, + async update(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.update(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_form_coa", false) + var msg = " Account " + prm.description + " sudah terupdate dong ..." + context.commit("update_msg_success", msg) + context.dispatch("search") + }else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + context.commit("update_alert_error", true) + console.log(e) + } + }, + + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + let resp = await api.xdelete(one_token(), prm.coid) + console.log(prm.coid) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_success", true) + + var msg = " Account " + prm.description + " sudah dihapus dong" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.commit("update_selected_coa", {}) + context.dispatch("search") + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + console.log(e) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/modules/periode.js b/test/vuex/acc-one-md-rk-type/modules/periode.js new file mode 100644 index 0000000..d9255d7 --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/modules/periode.js @@ -0,0 +1,160 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/api-periode.js" + +export default { + namespaced: true, + state: { + periode: [], + total_list: 0, + status_get: 0, + selected: {}, + snackbar: false, + message_snack: "" + }, + mutations: { + update_selected(state, data) { + state.selected = data + }, + update_total_list(state, data) { + state.total_list = data + }, + update_list(state, data) { + state.periode = data + }, + update_status_get(state, data) { + state.status_get = data + }, + open_snackbar(state, bool) { + state.snackbar = bool + }, + update_message_snack(state, data) { + state.message_snack = data + } + }, + actions: { + async getList(context) { + context.commit("update_status_get", 1); + try { + var params = {token: one_token()}; + let resp = await api.getListing(params); + if (resp.status != "OK") { + context.commit("update_status_get", 3); + context.commit("update_message_snack", resp.message); + context.commit("open_snackbar", true); + } else { + context.commit("update_status_get", 2); + let data = { + records: resp.data.records, + total: resp.data.total + } + // console.log(data.total); + // console.log(data.records); + context.commit("update_list", data.records); + context.commit("update_total_list", data.total); + } + } catch (error) { + context.commit("update_status_get", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async deletePeriode(context) { + try { + var params = { + token: one_token(), + id: context.state.selected.periodeID + } + console.log(params); + let resp = await api.p_delete(params); + if (resp.status != "OK") { + // console.log(resp.message); + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("open_snackbar", true); + var msg = "Berhasil menghapus data periode"; + context.commit("update_message_snack", msg); + context.commit("update_selected", {}); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async addPeriode(context) { + try { + var params = { + token: one_token(), + ...context.state.selected + }; + console.log(params); + let resp = await api.p_add(params); + if (resp.status != "OK") { + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("open_snackbar", true); + var msg = "Berhasil menyimpan data periode"; + context.commit("update_message_snack", msg); + context.commit("update_selected", {}); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async editPeriode(context) { + try { + var params = { + token: one_token(), + ...context.state.selected + }; + console.log(params); + let resp = await api.p_edit(params); + if (resp.status != "OK") { + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("open_snackbar", true); + var msg = "Berhasil menyimpan data periode"; + context.commit("update_message_snack", msg); + context.commit("update_selected", {}); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async checkNewOrEdit(context) { + if (!checkIsEmpty(context.state.selected)) { + var msg = "Form masih ada yang kosong"; + context.commit("update_message_snack", msg); + context.commit("open_snackbar", true); + return; + } + + if (!context.state.selected.periodeID) { + context.dispatch("addPeriode"); + } else { + context.dispatch("editPeriode"); + } + } + } +}; + +function checkIsEmpty(obj) { + if (Object.keys(obj).length === 0) { + return false; + } + + return obj.periodeYear && obj.periodeMonth && obj.periodeName && obj.periodeStartDate && obj.periodeEndDate; +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/modules/rktype.js b/test/vuex/acc-one-md-rk-type/modules/rktype.js new file mode 100644 index 0000000..c31844f --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/modules/rktype.js @@ -0,0 +1,182 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/rktype.js" + +export default { + namespaced: true, + state: { + typelist: [], + total_listtype: 0, + status_get: 0, + selected_type: {}, + snackbar: false, + message_snack: "", + errors: [], + save_status: 0, + act: "new", + search: "" + }, + mutations: { + update_selected_type(state, data) { + state.selected_type = data + }, + update_total_listtype(state, data) { + state.total_listtype = data + }, + update_typelist(state, data) { + state.typelist = data + }, + update_status_get(state, data) { + state.status_get = data + }, + open_snackbar(state, bool) { + state.snackbar = bool + }, + update_message_snack(state, data) { + state.message_snack = data + }, + update_errors(state, val) { + state.errors = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_act(state, val) { + state.act = val + }, + update_search(state, val) { + state.search = val + } + }, + actions: { + async getList(context) { + context.commit("update_status_get", 1); + try { + var prm = {token: one_token(), search: context.state.search}; + let resp = await api.getListing(prm); + if (resp.status != "OK") { + context.commit("update_status_get", 3); + context.commit("update_message_snack", resp.message); + context.commit("open_snackbar", true); + } else { + context.commit("update_status_get", 2); + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_typelist", data.records); + context.commit("update_total_listtype", data.total); + } + } catch (error) { + context.commit("update_status_get", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async delete(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token(); + let resp = await api.deleteRkType(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("update_save_status", 3); + context.commit("update_message_snack", resp.message); + + context.commit("open_snackbar", true); + var msg = "Berhasil menghapus data type"; + context.commit("update_message_snack", msg); + context.commit("update_selected_type", {}); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_save_status", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async save(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token(); + let resp = await api.saveRkType(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("update_save_status", 2); + context.commit("update_message_snack", resp.message); + + + context.commit("open_snackbar", true); + var msg = "Berhasil menyimpan data type"; + context.commit("update_message_snack", msg); + context.commit("update_selected_type", {}); + context.commit("update_errors", []); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_save_status", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async update(context, prm) { + context.commit("update_save_status", 1); + try { + prm.token = one_token() + let resp = await api.updateRkType(prm); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("open_snackbar", true); + context.commit("update_message_snack", resp.message); + } else { + context.commit("update_save_status", 2); + context.commit("update_message_snack", resp.message); + + context.commit("open_snackbar", true); + var msg = "Berhasil menyimpan data type"; + context.commit("update_message_snack", msg); + context.commit("update_selected_type", {}); + context.commit("update_errors", []); + context.dispatch("getList"); + } + } catch (error) { + context.commit("update_save_status", 3); + context.commit("update_message_snack", error.message); + context.commit("open_snackbar", true); + } + }, + + async checkNewOrEdit(context) { + if (!checkIsEmpty(context.state.selected_type)) { + var msg = "Form masih ada yang kosong"; + context.commit("update_message_snack", msg); + context.commit("open_snackbar", true); + return; + } + + if (!context.state.selected_type.periodeID) { + context.dispatch("addPeriode"); + } else { + context.dispatch("editPeriode"); + } + } + } +}; + +function checkIsEmpty(obj) { + if (Object.keys(obj).length === 0) { + return false; + } + + return obj.periodeYear && obj.periodeMonth && obj.periodeName && obj.periodeStartDate && obj.periodeEndDate; +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-rk-type/store.js b/test/vuex/acc-one-md-rk-type/store.js new file mode 100644 index 0000000..a476655 --- /dev/null +++ b/test/vuex/acc-one-md-rk-type/store.js @@ -0,0 +1,17 @@ +import rktype from "./modules/rktype.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + rktype: rktype, + system: system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}) \ No newline at end of file diff --git a/test/vuex/acc-one-md-ruangan/api/api.js b/test/vuex/acc-one-md-ruangan/api/api.js new file mode 100644 index 0000000..b63416b --- /dev/null +++ b/test/vuex/acc-one-md-ruangan/api/api.js @@ -0,0 +1,40 @@ +const URL = "/one-api/mockup/masterdata/accounting/Ruangan"; + +async function request(endpoint, param) { + try { + const resp = await axios.post(URL + endpoint, param); + if (resp.status !== 200) { + throw new Error(resp.statusText); + } + return resp.data; + } catch (e) { + return { + status: "ERR", + message: e.message + } + } +} + +export async function searchRuangan(param) { + return request("/lookupRuangan", param); +} + +export async function insertRuangan(param) { + return request("/insertRuangan", param); +} + +export async function updateRuangan(param) { + return request("/updateRuangan", param); +} + +export async function deleteRuangan(param) { + return request("/deleteRuangan", param); +} + +export async function listingCabang(param) { + return request("/listingCabang", param); +} + +export async function listingRegional(param) { + return request("/listingRegional", param); +} diff --git a/test/vuex/acc-one-md-ruangan/components/detail-layout.vue b/test/vuex/acc-one-md-ruangan/components/detail-layout.vue new file mode 100644 index 0000000..7a27286 --- /dev/null +++ b/test/vuex/acc-one-md-ruangan/components/detail-layout.vue @@ -0,0 +1,154 @@ + + + diff --git a/test/vuex/acc-one-md-ruangan/components/listing-layout.vue b/test/vuex/acc-one-md-ruangan/components/listing-layout.vue new file mode 100644 index 0000000..9f2551e --- /dev/null +++ b/test/vuex/acc-one-md-ruangan/components/listing-layout.vue @@ -0,0 +1,190 @@ + + + diff --git a/test/vuex/acc-one-md-ruangan/index.php b/test/vuex/acc-one-md-ruangan/index.php new file mode 100644 index 0000000..87be641 --- /dev/null +++ b/test/vuex/acc-one-md-ruangan/index.php @@ -0,0 +1,64 @@ + + + + + + + + + + ONE + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/test/vuex/acc-one-md-ruangan/modules/ruangan.js b/test/vuex/acc-one-md-ruangan/modules/ruangan.js new file mode 100644 index 0000000..c8f1362 --- /dev/null +++ b/test/vuex/acc-one-md-ruangan/modules/ruangan.js @@ -0,0 +1,228 @@ +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + snackbar: { + color: "success", + msg: "", + state: false + }, + + // left side + filter_listreg: [], + filter_listcab: [], + filter_listing: { + regional: "", + cabang: 0, + keyword: "" + }, + list_ruangan: { + total: 0, + records: [] + }, + list_pagination: 1, + + // right side + form_status: "BARU", + form_listreg: [], + form_listcab: [], + form_detail: { + id: 0, + nama: "", + kode: "", + cabang: "", + regional: "" + } + }, + mutations: { + update_snackbar(state, val) { + state.snackbar = val; + }, + + // left side + update_filter_listreg(state, val) { + state.filter_listreg = val; + }, + update_filter_listcab(state, val) { + state.filter_listcab = val; + }, + update_filter_listing(state, val) { + state.filter_listing = val; + }, + update_list_ruangan(state, val) { + state.list_ruangan = val; + }, + update_list_pagination(state, val) { + state.list_pagination = val; + }, + + // right side + update_form_status(state, val) { + state.form_status = val + }, + update_form_listreg(state, val) { + state.form_listreg = val; + }, + update_form_listcab(state, val) { + state.form_listcab = val; + }, + update_form_detail(state, val) { + state.form_detail = val + } + }, + actions: { + async listingRegional(context, side) { + try { + const param = { token: one_token() } + + const resp = await api.listingRegional(param); + if (resp.status != "OK") { + throw new Error(resp.message); + } + + const datas = resp.data.records; + const users = context.state.user; + + if (side == 'left') { + const sel_reg = datas.find((reg) => reg.S_RegionalID == users.S_RegionalID); + let filter = context.state.filter_listing; + filter.regional = sel_reg.S_RegionalID; + + context.commit("update_filter_listing", filter); + context.commit("update_filter_listreg", datas); + } else { + let reg = users.loginlevel == 'pusat' + ? datas + : datas.filter((r) => r.S_RegionalID == users.S_RegionalID); + context.commit("update_form_listreg", reg); + } + } catch (e) { + const snac = { color: 'error', msg: e.message, state: true }; + context.commit("update_snackbar", snac); + } + }, + + async listingCabang(context, side) { + try { + let param = { + token: one_token(), + regionalID: side == "left" + ? context.state.filter_listing.regional + : context.state.form_detail.regional + } + + const resp = await api.listingCabang(param); + if (resp.status != "OK") { + throw new Error(resp.message); + } + const users = context.state.user; + + if (side == "left") { + let datas = [{ M_BranchID: 0, M_BranchName: "SEMUA" }, ...resp.data.records] + const usr_cab = datas.find((cab) => cab.M_BranchID == users.M_BranchID); + let filter = context.state.filter_listing; + filter.cabang = usr_cab.M_BranchID; + + context.commit("update_filter_listing", filter); + context.commit("update_filter_listcab", datas); + } else { + context.commit("update_form_listcab", resp.data.records); + } + } catch (e) { + const snac = { color: 'error', msg: e.message, state: true }; + context.commit("update_snackbar", snac); + } + }, + + async searchRuangan(context) { + try { + const param = { + token: one_token(), + latestPage: context.state.list_pagination, + regionalID: context.state.filter_listing.regional, + branchID: context.state.filter_listing.cabang ?? 0 + } + + const resp = await api.searchRuangan(param); + if (resp.status != "OK") { + throw new Error(resp.message); + } + + context.commit("update_list_ruangan", resp.data); + } catch (e) { + const snac = { color: 'error', msg: e.message, state: true }; + context.commit("update_snackbar", snac); + } + }, + + async insertRuangan(context) { + try { + const param = { + token: one_token(), + regionalID: context.state.form_detail.regional, + branchID: context.state.form_detail.cabang, + ruanganName: context.state.form_detail.nama, + ruanganCode: context.state.form_detail.kode + } + + const resp = await api.insertRuangan(param); + if (resp.status != "OK") { + throw new Error(resp.message); + } + + const snac = { color: 'success', msg: "sukses insert data ruangan", state: true }; + context.commit("update_snackbar", snac); + } catch (e) { + const snac = { color: 'error', msg: e.message, state: true }; + context.commit("update_snackbar", snac); + } + }, + + async updateRuangan(context, id) { + try { + const param = { + token: one_token(), + ruanganID: id, + regionalID: context.state.form_detail.regional, + branchID: context.state.form_detail.cabang, + ruanganName: context.state.form_detail.nama, + ruanganCode: context.state.form_detail.kode + } + console.log(param); + + const resp = await api.updateRuangan(param); + if (resp.status != "OK") { + throw new Error(resp.message); + } + + const snac = { color: 'success', msg: "sukses update data ruangan", state: true }; + context.commit("update_snackbar", snac); + } catch (e) { + const snac = { color: 'error', msg: e.message, state: true }; + context.commit("update_snackbar", snac); + } + }, + + async deleteRuangan(context, id) { + try { + const param = { + token: one_token(), + ruanganID: id + } + + const resp = await api.deleteRuangan(param); + if (resp.status != "OK") { + throw new Error(resp.message); + } + + const snac = { color: 'success', msg: "sukses delete data ruangan", state: true }; + context.commit("update_snackbar", snac); + } catch (e) { + const snac = { color: 'error', msg: e.message, state: true }; + context.commit("update_snackbar", snac); + } + }, + } +} diff --git a/test/vuex/acc-one-md-ruangan/store.js b/test/vuex/acc-one-md-ruangan/store.js new file mode 100644 index 0000000..aa1003e --- /dev/null +++ b/test/vuex/acc-one-md-ruangan/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import ruangan from "./modules/ruangan.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + ruangan: ruangan + }, + state: {}, + mutations: {}, + actions: {} +}); diff --git a/test/vuex/acc-one-md-supplier/api/supplier.js b/test/vuex/acc-one-md-supplier/api/supplier.js new file mode 100644 index 0000000..3acc77e --- /dev/null +++ b/test/vuex/acc-one-md-supplier/api/supplier.js @@ -0,0 +1,200 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'supplier/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchdetail(prm) { + try { + var resp = await axios.post(URL + 'supplier/searchdetail', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(prm) { + try { + var resp = await axios.post(URL + "supplier/save", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function update(prm) { + try { + var resp = await axios.post(URL + "supplier/update", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deletesupplier(prm) { + try { + var resp = await axios.post(URL + "supplier/deletesupplier", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchItem(token, prm) { + try { + var resp = await axios.post(URL + 'supplier/searchItem', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUnit(prm) { + try { + var resp = await axios.post(URL + 'supplier/getUnit', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveprice(prm) { + try { + var resp = await axios.post(URL + "supplier/saveprice", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateprice(prm) { + try { + var resp = await axios.post(URL + "supplier/updateprice", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteprice(prm) { + try { + var resp = await axios.post(URL + "supplier/deleteprice", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-supplier/components/oneSupplierDetail.vue b/test/vuex/acc-one-md-supplier/components/oneSupplierDetail.vue new file mode 100644 index 0000000..6433e70 --- /dev/null +++ b/test/vuex/acc-one-md-supplier/components/oneSupplierDetail.vue @@ -0,0 +1,759 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-supplier/components/oneSupplierList.vue b/test/vuex/acc-one-md-supplier/components/oneSupplierList.vue new file mode 100644 index 0000000..258fb98 --- /dev/null +++ b/test/vuex/acc-one-md-supplier/components/oneSupplierList.vue @@ -0,0 +1,626 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-supplier/index.php b/test/vuex/acc-one-md-supplier/index.php new file mode 100644 index 0000000..c736a26 --- /dev/null +++ b/test/vuex/acc-one-md-supplier/index.php @@ -0,0 +1,91 @@ + + + + + + + + One + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-supplier/modules/supplier.js b/test/vuex/acc-one-md-supplier/modules/supplier.js new file mode 100644 index 0000000..b461f0f --- /dev/null +++ b/test/vuex/acc-one-md-supplier/modules/supplier.js @@ -0,0 +1,478 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/supplier.js" + +export default { + namespaced: true, + state: { + search_status: 0, + search_error_message: "", + suppliers: [], + selected_supplier: {}, + total_page: 0, + current_page: 1, + xsearch: "", + last_id: -1, + dialog_form: false, + act: "new", + errors: "", + save_status: 0, + save_error_message: "", + alert_error: false, + alert_success: false, + msg_success: "", + + // detail + search_status_detail: 0, + search_error_detail_message: "", + supplier_prices: [], + selected_supplier_price: {}, + total_page_supplier_price: 0, + current_page_detail: 1, + xsearch_detail: "", + selected_supplier_id: 0, + dialog_form_detail: false, + act_detail: "new", + loading_autocomplete: false, + itemList: [], + selected_item: {}, + itemUnits: [], + selected_unit: {}, + alert_error_detail: false, + alert_success_detail: false, + selected_type: {id:"1", name:"Tak Terhingga", value:"T"}, + min_value:'', + max_value:'', + min_inclusive:false, + max_inclusive:false, + }, + mutations: { + update_search_status(state, val) { + state.search_status = val + }, + update_search_error_message(state, val) { + state.search_error_message = val + }, + update_suppliers(state, val) { + state.suppliers = val + }, + update_selected_supplier(state, val) { + state.selected_supplier = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_xsearch(state, val) { + state.xsearch = val + state.current_page = 1 + }, + update_last_id(state, val) { + state.last_id = val + }, + update_dialog_form(state, val) { + state.dialog_form = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_alert_error(state, val) { + state.alert_error = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + + // detail + update_search_status_detail(state, val) { + state.search_status_detail = val + }, + update_search_error_detail_message(state, val) { + state.search_error_detail_message = val + }, + update_supplier_prices(state, val) { + state.supplier_prices = val + }, + update_selected_supplier_price(state, val) { + state.selected_supplier_price = val + }, + update_total_page_supplier_price(state, val) { + state.total_page_supplier_price = val + }, + update_current_page_detail(state, val) { + state.current_page_detail = val + }, + update_xsearch_detail(state, val) { + state.xsearch_detail = val + state.current_page_detail = 1 + }, + update_selected_supplier_id(state, val) { + state.selected_supplier_id = val + }, + update_errors(state, val) { + state.errors = val + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val + }, + update_act_detail(state, val) { + state.act_detail = val + }, + update_loading_autocomplete(state, val) { + state.loading_autocomplete = val + }, + update_itemList(state, val) { + state.itemList = val + }, + update_selected_item(state, val) { + state.selected_item = val + }, + update_itemUnits(state, val) { + state.itemUnits = val + }, + update_selected_unit(state, val) { + state.selected_unit = val + }, + update_alert_error_detail(state, val) { + state.alert_error_detail = val + }, + update_alert_success_detail(state, val) { + state.alert_success_detail = val + }, + update_selected_type(state, val) { + state.selected_type = val + }, + update_min_inclusive(state, val) { + state.min_inclusive = val + }, + update_max_inclusive(state, val) { + state.max_inclusive = val + }, + update_min_value(state, val) { + state.min_value = val + }, + update_max_value(state, val) { + state.max_value = val + } + }, + actions: { + async search(context) { + context.commit("update_search_status", 1) + try { + var prm = { + token: one_token(), + current_page: context.state.current_page, + search: context.state.xsearch, + last_id: -1 + } + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_status", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total_page + } + + context.commit("update_suppliers", data.records) + context.commit("update_total_page", data.total) + + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_search_error_message", e.message) + } + }, + async searchdetail(context) { + context.commit("update_search_status_detail", 1) + try { + var prm = { + token: one_token(), + current_page: context.state.current_page_detail, + search: context.state.xsearch_detail, + supplier_id: context.state.selected_supplier.SupplierID + } + let resp = await api.searchdetail(prm) + if (resp.status != "OK") { + context.commit("update_search_status_detail", 3) + context.commit("update_search_error_detail_message", resp.message) + } else { + context.commit("update_search_status_detail", 2) + context.commit("update_search_error_detail_message", "") + let data = { + records: resp.data.records, + total: resp.data.total_page + } + + context.commit("update_supplier_prices", data.records) + context.commit("update_total_page_supplier_price", data.total) + + } + } catch (e) { + context.commit("update_search_status_detail", 3) + context.commit("update_search_error_detail_message", e.message) + } + }, + async save(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = `Supplier baru dengan kode ${data.records[0].SupplierCode} sudah tersimpan`; + context.commit("update_msg_success", msg) + context.dispatch("search") + context.commit("update_selected_supplier", data.records[0]); + context.dispatch("searchdetail") + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + }, + async update(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.update(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = `Perubahan supplier dengan kode ${data.records[0].SupplierCode} sudah tersimpan`; + context.commit("update_msg_success", msg) + context.dispatch("search") + context.commit("update_selected_supplier", data.records[0]); + context.dispatch("searchdetail") + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + }, + async deletesupplier(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deletesupplier(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form", false) + var msg = "Supplier dengan kode " + prm.codeSupplier + " sudah dihapus"; + context.commit("update_msg_success", msg) + context.dispatch("search") + context.dispatch("searchdetail") + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error", true) + } + }, + + async searchItem(context, prm) { + context.commit("update_loading_autocomplete", true) + try { + let resp = await api.searchItem(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_loading_autocomplete", false) + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_loading_autocomplete", false) + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_itemList", data.records) + } + } catch (e) { + context.commit("update_loading_autocomplete", true) + context.commit("update_search_error_message", e.message); + } + }, + + async getUnit(context, prm) { + context.commit("update_loading_autocomplete", true) + try { + prm.token = one_token() + let resp = await api.getUnit(prm) + if (resp.status != "OK") { + context.commit("update_loading_autocomplete", false) + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_loading_autocomplete", false) + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_itemUnits", data.records) + } + } catch (e) { + context.commit("update_loading_autocomplete", true) + context.commit("update_search_error_message", e.message); + } + }, + + async saveprice(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.saveprice(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error_detail", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success_detail", true) + context.commit("update_dialog_form_detail", false) + var msg = "Harga baru berhasil ditambahkan"; + context.commit("update_msg_success", msg) + context.commit("update_selected_supplier_price", data.records[0]); + context.dispatch("searchdetail") + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error_detail", true) + } + }, + + async updateprice(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.updateprice(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error_detail", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success_detail", true) + context.commit("update_dialog_form_detail", false) + var msg = "Harga baru berhasil di update"; + context.commit("update_msg_success", msg) + context.commit("update_selected_supplier_price", data.records[0]); + context.dispatch("searchdetail") + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error_detail", true) + } + }, + + async deleteprice(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteprice(prm); + if (resp.status != "OK") { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error_detail", true) + } else { + context.commit("update_save_error_message", resp.message) + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + }; + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success_detail", true) + var msg = "Harga baru berhasil di hapus"; + context.commit("update_msg_success", msg) + context.dispatch("searchdetail") + } + } + } catch (e) { + context.commit("update_save_error_message", e.message) + context.commit("update_save_status", 3) + context.commit("update_alert_error_detail", true) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-supplier/store.js b/test/vuex/acc-one-md-supplier/store.js new file mode 100644 index 0000000..90995df --- /dev/null +++ b/test/vuex/acc-one-md-supplier/store.js @@ -0,0 +1,11 @@ +import supplier from "./modules/supplier.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + supplier: supplier, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-md-unitconvert/api/itemunitconvert.js b/test/vuex/acc-one-md-unitconvert/api/itemunitconvert.js new file mode 100644 index 0000000..bae8e37 --- /dev/null +++ b/test/vuex/acc-one-md-unitconvert/api/itemunitconvert.js @@ -0,0 +1,133 @@ +const URL = "/one-api/mockup/masterdata/accounting/" + +export async function searchitem(prm) { + try { + var resp = await axios.post(URL + 'unitconvert/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchitemx(prm) { + try { + var resp = await axios.post(URL + 'unitconvert/searchitemx', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function fromitemunit(prm) { + try { + var resp = await axios.post(URL + 'unitconvert/fromitemunit', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function toitemunit(prm) { + try { + var resp = await axios.post(URL + 'unitconvert/toitemunit', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveAdd(prm) { + try { + var resp = await axios.post(URL + 'unitconvert/save', prm); + if (resp.status != 200) { + return { + status: "ERR", + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveedit(prm) { + try { + var resp = await axios.post(URL + 'unitconvert/edit', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(prm) { + try { + var resp = await axios.post(URL + 'unitconvert/delete', prm); + if (resp.status != 200) { + return { + status: "ERR", + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-unitconvert/components/oneMdItemUnitConvert.vue b/test/vuex/acc-one-md-unitconvert/components/oneMdItemUnitConvert.vue new file mode 100644 index 0000000..d4c656d --- /dev/null +++ b/test/vuex/acc-one-md-unitconvert/components/oneMdItemUnitConvert.vue @@ -0,0 +1,794 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-unitconvert/index.php b/test/vuex/acc-one-md-unitconvert/index.php new file mode 100644 index 0000000..4327023 --- /dev/null +++ b/test/vuex/acc-one-md-unitconvert/index.php @@ -0,0 +1,70 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-md-unitconvert/modules/itemunitconvert.js b/test/vuex/acc-one-md-unitconvert/modules/itemunitconvert.js new file mode 100644 index 0000000..be4ba1f --- /dev/null +++ b/test/vuex/acc-one-md-unitconvert/modules/itemunitconvert.js @@ -0,0 +1,320 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/itemunitconvert.js" + +export default { + namespaced: true, + state: { + dialog_form: false, + itemunitconvert: [], + search_status: 0, + total_itemunitconverts: 0, + current_page: 1, + selected_itemunitconvert: {}, + x_search: "", + pagination:{ + descending:'asc', + sortBy: 'UnitConvertID' + }, + last_id: -1, + itemx: [], + item_convert: {}, + fromitemunits: [], + fromitemunit_convert: {}, + toitemunits: [], + toitemunit_convert: {}, + act: "add", + save_status: 0, + msg_success: "", + errors: [], + loading_save:false, + error_message: '', + save_error_message: "", + last_id: -1, + dialog_error:false, + alert_success: false, + get_data_status:false + }, + mutations: { + update_get_data_status(state, val) { + state.get_data_status = val + }, + update_dialog_form(state, val) { + state.dialog_form = val + }, + update_itemunitconvert(state, data){ + state.itemunitconvert = data + }, + update_search_status(state, status){ + state.search_status = status + }, + update_total_itemunitconverts(state,val) { + state.total_itemunitconverts = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_selected_itemunitconvert(state, val) { + state.selected_itemunitconvert = val + }, + update_pagination(state, val) { + state.pagination = val + }, + update_x_search(state, val) { + state.x_search = val + state.current_page = 1 + }, + update_last_id(state, val) { + state.last_id = val + }, + update_itemx(state, val) { + state.itemx = val + }, + update_item_convert(state, val) { + state.item_convert = val + }, + update_fromitemunits(state, val) { + state.fromitemunits = val + }, + update_fromitemunit_convert(state, val){ + state.fromitemunit_convert = val + }, + update_toitemunits(state, val) { + state.toitemunits = val + }, + update_toitemunit_convert(state, val){ + state.toitemunit_convert = val + }, + update_act(state, val) { + state.act = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_errors(state, val) { + state.errors = val + }, + update_loading_save(state, data) { + state.loading_save = data + }, + update_error_message(state, data) { + state.error_message = data + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_dialog_error(state, data) { + state.dialog_error = data + } + }, + actions: { + async search(context) { + context.commit("update_search_status", 1) + + try { + var prm = { + token: one_token(), + search: context.state.x_search, + sortBy: context.state.pagination.sortBy, + sortStatus: context.state.pagination.descending, + current_page: context.state.current_page + } + + let resp = await api.searchitem(prm) + if (resp.status != "OK") { + context.commit("update_search_status", false) + } else { + context.commit("update_search_status", false) + let data = { + records: resp.data.records, + total: resp.data.total_page, + total_filter: resp.data.total_filter + } + context.commit("update_itemunitconvert", resp.data.records) + context.commit("update_total_itemunitconverts", resp.data.total_page) + if(context.state.last_id == -1){ + if(resp.data && resp.data.records.length > 0){ + context.commit("update_selected_itemunitconvert", resp.data.records[0]) + } + } + else{ + if(resp.data && resp.data.records.length > 0){ + let idx = _.findIndex(resp.data.records, function(o) { return o.id == context.state.last_id}) + context.commit("update_selected_itemunitconvert", resp.data.records[idx]) + } + } + } + } catch (e) { + context.commit("update_search_status", false) + // console.log(e) + } + }, + + async searchitemx(context) { + try { + let prm = { + token: one_token(), + } + let resp = await api.searchitemx(prm) + if (resp.status != "OK") { + console.log(resp.message) + } else { + let data = resp.data.records; + context.commit("update_itemx", resp.data.records) + } + } catch (e) { + console.log(e) + } + }, + + async fromitemunit(context,search) { + context.commit("update_get_data_status",true) + try { + let prm = {} + prm.token = one_token() + prm.search = search + + let resp = await api.fromitemunit(prm) + if (resp.status != "OK") { + console.log(resp.message); + context.commit("update_get_data_status",false) + } else { + context.commit("update_get_data_status",false) + let data = { + records: resp.data.records + } + context.commit("update_fromitemunits", resp.data.records) + } + } catch (e) { + context.commit("update_get_data_status",false) + console.log(e); + } + }, + async toitemunit(context,search) { + context.commit("update_get_data_status",true) + try { + let prm = {} + prm.token = one_token() + prm.search = search + + let resp = await api.fromitemunit(prm) + if (resp.status != "OK") { + console.log(resp.message); + context.commit("update_get_data_status",false) + } else { + context.commit("update_get_data_status",false) + let data = { + records: resp.data.records + } + context.commit("update_toitemunits", resp.data.records) + } + } catch (e) { + context.commit("update_get_data_status",false) + console.log(e); + } + }, + + + async save(context, prm) { + context.commit("update_save_status", 1) + try { + context.commit("update_loading_save", true) + prm.token = one_token() + let resp = await api.saveAdd(prm) + + if (resp.status != "OK") { + context.commit("update_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_loading_save", false) + } else { + context.commit("update_save_status", 2) + context.commit("update_loading_save", false) + context.commit("update_save_error_message", "") + let data = { + total: resp.data.total, + records: resp.data.records + } + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_dialog_form", false) + var msg = "Konversi satuan sudah tersimpan" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.dispatch("search") + } else { + context.commit("update_errors", resp.data.errors) + } + } + } catch (e) { + context.commit("update_error_message", resp.message) + context.commit("update_save_status", 3) + context.commit("update_loading_save", false) + } + }, + + async saveEdit(context, prm) { + context.commit("update_save_status", 1) + try { + context.commit("update_loading_save", true) + prm.token = one_token() + let resp = await api.saveedit(prm) + + if (resp.status != "OK") { + context.commit("update_error_message", resp.message) + context.commit("update_dialog_error", true) + context.commit("update_loading_save", false) + } else { + context.commit("update_loading_save", false) + context.commit("update_dialog_error", false) + context.commit("update_save_error_message", "") + context.commit("update_dialog_form", false) + var msg = "Konversi satuan sudah terupdate" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.dispatch("search") + } + } catch (e) { + context.commit("update_error_message", e.message) + context.commit("update_dialog_error", true) + context.commit("update_loading_save", false) + console.log(e) + } + }, + + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + context.commit("update_loading_save", true) + prm.token = one_token() + let resp = await api.xdelete(prm) + + if (resp.status != "OK") { + context.commit("update_error_message", resp.message) + context.commit("update_dialog_error", true) + context.commit("update_loading_save", false) + } else { + context.commit("update_loading_save", false) + context.commit("update_dialog_error", false) + context.commit("update_save_error_message", "") + context.commit("update_dialog_form", false) + var msg = "Konversi satuan sudah terhapus" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.dispatch("search") + } + } catch (e) { + context.commit("update_error_message", e.message) + context.commit("update_dialog_error", true) + context.commit("update_loading_save", false) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-md-unitconvert/store.js b/test/vuex/acc-one-md-unitconvert/store.js new file mode 100644 index 0000000..63a4746 --- /dev/null +++ b/test/vuex/acc-one-md-unitconvert/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import itemunitconvert from "./modules/itemunitconvert.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + itemunitconvert: itemunitconvert, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-handover/api/api.js b/test/vuex/acc-one-mutasi-handover/api/api.js new file mode 100644 index 0000000..e39647b --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/api/api.js @@ -0,0 +1,249 @@ +const URL = "/one-api/mockup/mutasi/"; + +export async function search(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/search', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getCategory(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/getCategory', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBranchAsal(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/getBranchAsal', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBranchTujuan(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/getBranchTujuan', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getReceiveOrderPo(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/getReceiveOrderPo', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemReceive(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/getItemReceive', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveMutasi(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/saveMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemMutasiUpdate(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/getItemMutasiUpdate', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditMutasi(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/saveEditMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function deleteMutasi(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/deleteMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + + +export async function getApproveLevel(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/getApproveLevel', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function approveMutasiRequest(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/approveMutasiRequest', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function sendHandoverMutasi(params) { + try { + var resp = await axios.post(URL + 'HandoverMutasi/sendHandoverMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasi.vue b/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasi.vue new file mode 100644 index 0000000..f8f0ded --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasi.vue @@ -0,0 +1,307 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasiSend.vue b/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasiSend.vue new file mode 100644 index 0000000..cc58a38 --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasiSend.vue @@ -0,0 +1,302 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasiView.vue b/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasiView.vue new file mode 100644 index 0000000..ecd7aba --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/components/dialogFormMutasiView.vue @@ -0,0 +1,301 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-handover/components/dialogSelectItem.vue b/test/vuex/acc-one-mutasi-handover/components/dialogSelectItem.vue new file mode 100644 index 0000000..6063d93 --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/components/dialogSelectItem.vue @@ -0,0 +1,342 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-handover/components/mutasiListing.vue b/test/vuex/acc-one-mutasi-handover/components/mutasiListing.vue new file mode 100644 index 0000000..300a930 --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/components/mutasiListing.vue @@ -0,0 +1,599 @@ + + + + + diff --git a/test/vuex/acc-one-mutasi-handover/index.php b/test/vuex/acc-one-mutasi-handover/index.php new file mode 100644 index 0000000..77404c2 --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/index.php @@ -0,0 +1,115 @@ + + + + + + + + + + + One + + + + + + + + + Error + + + + {{errMessage}} + + + + + + + + Tutup + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-handover/modules/form.js b/test/vuex/acc-one-mutasi-handover/modules/form.js new file mode 100644 index 0000000..7547f60 --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/modules/form.js @@ -0,0 +1,315 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + dialog_form_mutasi: false, + mutasi_date: moment(new Date()).format('YYYY-MM-DD'), + list_category: [], + selected_category: {}, + list_branch_asal: [], + selected_branch_asal: {}, + list_branch_tujuan: [], + selected_branch_tujuan: {}, + note: '', + dialog_select_item: false, + list_ro: [], + selected_ro: {}, + current_page: 1, + x_search: '', + total_pages: 0, + list_item_receive: [], + select_item_temp: [], + list_mutasi_item: [], + dialog_form_mutasi_verif: false, + dialog_form_mutasi_approve: false + }, + mutations: { + update_dialog_form_mutasi(state, val) { + state.dialog_form_mutasi = val; + }, + update_mutasi_date(state, val) { + state.mutasi_date = val; + }, + update_list_category(state, val) { + state.list_category = val; + }, + update_selected_category(state, val) { + state.selected_category = val; + }, + update_list_branch_asal(state, val) { + state.list_branch_asal = val; + }, + update_selected_branch_asal(state, val) { + state.selected_branch_asal = val; + }, + update_list_branch_tujuan(state, val) { + state.list_branch_tujuan = val; + }, + update_selected_branch_tujuan(state, val) { + state.selected_branch_tujuan = val; + }, + update_note(state, val) { + state.note = val; + }, + update_dialog_select_item(state, val) { + state.dialog_select_item = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_total_pages(state, val) { + state.total_pages = val; + }, + update_list_item_receive(state, val) { + state.list_item_receive = val; + }, + update_select_item_temp(state, val) { + state.select_item_temp = val; + }, + update_list_ro(state, val) { + state.list_ro = val; + }, + update_selected_ro(state, val) { + state.selected_ro = val; + }, + update_list_mutasi_item(state, val) { + state.list_mutasi_item = val; + }, + update_dialog_form_mutasi_verif(state, val) { + state.dialog_form_mutasi_verif = val + }, + update_dialog_form_mutasi_approve(state, val) { + state.dialog_form_mutasi_approve = val + } + }, + actions: { + resetForm(context) { + context.state.mutasi_date = moment(new Date()).format('YYYY-MM-DD') + context.state.selected_category = {} + context.state.selected_branch_asal = {} + context.state.selected_branch_tujuan = {} + context.state.note = '' + context.state.list_mutasi_item = [] + }, + + async getCategory(context) { + try { + let param = { + token: one_token(), + search: '' + } + const resp = await api.getCategory(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_category", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getBranchAsal(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getBranchAsal(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_branch_asal", resp.data.records); + context.commit("update_selected_branch_asal", resp.data.records[0]); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getBranchTujuan(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getBranchTujuan(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_branch_tujuan", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getReceiveOrderPo(context) { + try { + let param = { + token: one_token(), + branchAsalCode: context.state.selected_branch_asal.M_BranchCode, + itemCategoryID: context.state.selected_category.itemCategoryID, + search: '', + } + const resp = await api.getReceiveOrderPo(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_ro", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getItemReceive(context) { + try { + let param = { + token: one_token(), + warhouseID: context.state.selected_ro.ReceiveOrderPoWarehouseID, + branchAsalCode: context.state.selected_ro.ReceiveOrderPoM_BranchCode, + receiveOrderPoID: context.state.selected_ro.ReceiveOrderPoID, + search: '', + current_page: context.state.current_page + } + const resp = await api.getItemReceive(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_item_receive", resp.data.records); + context.commit("update_total_pages", resp.data.total_page); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async saveMutasi(context) { + try { + let param = { + token: one_token(), + mutasi_date: context.state.mutasi_date, + category_id: context.state.selected_category.itemCategoryID, + branch_asal_id: context.state.selected_branch_asal.M_BranchID, + branch_tujuan_id: context.state.selected_branch_tujuan.M_BranchID, + note: context.state.note, + list_mutasi: context.state.list_mutasi_item + } + const resp = await api.saveMutasi(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.dispatch("resetForm"); + context.dispatch("mutasi/search", {}, {root: true}); + + context.commit("mutasi/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + + context.commit("update_dialog_form_mutasi", false); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async saveEditMutasi(context) { + try { + let param = { + token: one_token(), + mutasi_request_id: context.rootState.mutasi.selected_list_data.MutasiRequestID, + mutasi_date: context.state.mutasi_date, + category_id: context.state.selected_category.itemCategoryID, + branch_asal_id: context.state.selected_branch_asal.M_BranchID, + branch_tujuan_id: context.state.selected_branch_tujuan.M_BranchID, + note: context.state.note, + list_mutasi: context.state.list_mutasi_item + } + const resp = await api.saveEditMutasi(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.dispatch("resetForm"); + context.dispatch("mutasi/search", {}, {root: true}); + + context.commit("mutasi/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + + context.commit("update_dialog_form_mutasi_approve", false); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-handover/modules/mutasi.js b/test/vuex/acc-one-mutasi-handover/modules/mutasi.js new file mode 100644 index 0000000..30a861b --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/modules/mutasi.js @@ -0,0 +1,355 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + alert_error: false, + err_message: "", + menu_start_date: false, + menu_end_date: false, + d_start_date: new Date().toISOString().substring(0, 10), + d_end_date: new Date().toISOString().substring(0, 10), + f_start_date: moment(new Date()).format("YYYY-MM-DD"), + f_end_date: moment(new Date()).format("YYYY-MM-DD"), + f_status: '', + status_options: [ + { text: 'All', value: '' }, + { text: 'Draft', value: 'Draft' }, + { text: 'Verified', value: 'Verified' }, + { text: 'Approved', value: 'Approved' }, + { text: 'Rejected', value: 'Rejected' }, + { text: 'sent', value: 'sent' }, + { text: 'Received', value: 'Received' }, + { text: 'Done', value: 'Done' }, + ], + f_search : '', + list_data: [], + selected_list_data: {}, + isLoading: 0, + current_page: 1, + total_pages: 0, + snackbar: { + color: 'success', + msg: '', + isOpen: false + }, + dialog_delete: false, + approve_level: 0, + dialog_reject: false, + note_reject: '', + dialog_form_mutasi_send: false, + dialog_form_mutasi_view: false + }, + mutations: { + update_alert_error(state, val) { + state.alert_error = val; + }, + update_err_message(state, val) { + state.err_message = val; + }, + update_menu_start_date(state, val) { + state.menu_start_date = val; + }, + update_menu_end_date(state, val) { + state.menu_end_date = val; + }, + update_d_start_date(state, val) { + state.d_start_date = val; + }, + update_d_end_date(state, val) { + state.d_end_date = val; + }, + update_f_start_date(state, val) { + state.f_start_date = val; + }, + update_f_end_date(state, val) { + state.f_end_date = val; + }, + update_f_status(state, val) { + state.f_status = val; + }, + update_status_options(state, val) { + state.status_options = val; + }, + update_f_search(state, val) { + state.f_search = val; + state.current_page = 1 + }, + update_list_data(state, val) { + state.list_data = val; + }, + update_selected_list_data(state, val) { + state.selected_list_data = val; + }, + update_isLoading(state, val) { + state.isLoading = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_total_pages(state, val) { + state.total_pages = val; + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_dialog_delete(state, val) { + state.dialog_delete = val + }, + update_approve_level(state, data) { + state.approve_level = data + }, + update_dialog_reject(state, val) { + state.dialog_reject = val + }, + update_note_reject(state, val) { + state.note_reject = val + }, + update_dialog_form_mutasi_send(state, val) { + state.dialog_form_mutasi_send = val + }, + update_dialog_form_mutasi_view(state, val) { + state.dialog_form_mutasi_view = val + } + }, + actions: { + async search(context) { + context.commit("update_isLoading", 1) + try { + let param = { + token: one_token(), + search: context.state.f_search, + start_date: context.state.f_start_date, + end_date: context.state.f_end_date, + current_page: context.state.current_page, + status: context.state.f_status + } + const resp = await api.search(param); + if (resp.status != 'OK') { + context.commit("update_isLoading", 3) + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_isLoading", 2) + context.commit("update_list_data", resp.data.records); + context.commit("update_total_pages", resp.data.total_page); + } + } catch (error) { + context.commit("update_isLoading", 3) + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getItemMutasiUpdate(context) { + try { + let param = { + token: one_token(), + mutasiRequestID: context.state.selected_list_data.MutasiRequestID + } + const resp = await api.getItemMutasiUpdate(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("form/update_mutasi_date", context.state.selected_list_data.MutasiRequestDate, { root: true }); + + let category = { + itemCategoryID: context.state.selected_list_data.itemCategoryID, + itemCategoryName: context.state.selected_list_data.itemCategoryName + } + context.commit("form/update_selected_category", category, { root: true }); + + let branch_asal = { + M_BranchID: context.state.selected_list_data.branch_asal_id, + M_BranchName: context.state.selected_list_data.branch_asal_name, + M_BranchCode: context.state.selected_list_data.branch_asal_code, + } + context.commit("form/update_selected_branch_asal", branch_asal, { root: true }); + + let branch_tujuan = { + M_BranchID: context.state.selected_list_data.branch_tujuan_id, + M_BranchName: context.state.selected_list_data.branch_tujuan_name, + M_BranchCode: context.state.selected_list_data.branch_tujuan_code, + } + context.commit("form/update_selected_branch_tujuan", branch_tujuan, { root: true }); + + context.commit("form/update_note", context.state.selected_list_data.MutasiRequestNote, { root: true }); + context.commit("form/update_list_mutasi_item", resp.data.records, { root: true }); + + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async deleteMutasi(context) { + try { + let param = { + token: one_token(), + mutasiRequestID: context.state.selected_list_data.MutasiRequestID + } + const resp = await api.deleteMutasi(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit('update_dialog_delete', false) + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async getApproveLevel(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getApproveLevel(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + let data = resp.data.M_UserM_ApproveLevelID + + context.commit("update_approve_level", data) + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async verifMutasiRequest(context, param) { + try { + param.token = one_token() + param.approvelevel = context.state.approve_level + const resp = await api.approveMutasiRequest(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit("form/update_dialog_form_mutasi_verif", false, { root: true }); + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async approveMutasiRequest(context, param) { + try { + param.token = one_token() + param.approvelevel = context.state.approve_level + const resp = await api.approveMutasiRequest(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit("form/update_dialog_form_mutasi_approve", false, { root: true }); + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async sendHandoverMutasi(context) { + try { + let param = { + token: one_token(), + header: context.state.selected_list_data, + detail: context.rootState.form.list_mutasi_item + } + const resp = await api.sendHandoverMutasi(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit("update_dialog_form_mutasi_send", false); + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-handover/store.js b/test/vuex/acc-one-mutasi-handover/store.js new file mode 100644 index 0000000..e653595 --- /dev/null +++ b/test/vuex/acc-one-mutasi-handover/store.js @@ -0,0 +1,13 @@ +import mutasi from "./modules/mutasi.js"; +import form from "./modules/form.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + mutasi: mutasi, + form: form, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-mutasi-receive/api/api.js b/test/vuex/acc-one-mutasi-receive/api/api.js new file mode 100644 index 0000000..290f77c --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/api/api.js @@ -0,0 +1,172 @@ +const URL = "/one-api/mockup/mutasi/"; + +export async function search(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/search', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getCategory(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/getCategory', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBranchAsal(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/getBranchAsal', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBranchTujuan(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/getBranchTujuan', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemDetail(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/getItemDetail', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getWarehouse(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/getWarehouse', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getRuangan(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/getRuangan', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function receive(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/receive', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBarcodes(params) { + try { + var resp = await axios.post(URL + 'ReceiveMutasi/getBarcodes', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasi.vue b/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasi.vue new file mode 100644 index 0000000..f8f0ded --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasi.vue @@ -0,0 +1,307 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasiReceive.vue b/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasiReceive.vue new file mode 100644 index 0000000..8816b7b --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasiReceive.vue @@ -0,0 +1,316 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasiView.vue b/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasiView.vue new file mode 100644 index 0000000..2ad1880 --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/components/dialogFormMutasiView.vue @@ -0,0 +1,341 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/components/dialogPrintBarcode.vue b/test/vuex/acc-one-mutasi-receive/components/dialogPrintBarcode.vue new file mode 100644 index 0000000..a23ad83 --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/components/dialogPrintBarcode.vue @@ -0,0 +1,177 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/components/dialogSelectItem.vue b/test/vuex/acc-one-mutasi-receive/components/dialogSelectItem.vue new file mode 100644 index 0000000..6063d93 --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/components/dialogSelectItem.vue @@ -0,0 +1,342 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/components/mutasiListing.vue b/test/vuex/acc-one-mutasi-receive/components/mutasiListing.vue new file mode 100644 index 0000000..a218c1a --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/components/mutasiListing.vue @@ -0,0 +1,630 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/index.php b/test/vuex/acc-one-mutasi-receive/index.php new file mode 100644 index 0000000..21dd4f5 --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/index.php @@ -0,0 +1,116 @@ + + + + + + + + + + + One + + + + + + + + + Error + + + + {{errMessage}} + + + + + + + + Tutup + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/modules/form.js b/test/vuex/acc-one-mutasi-receive/modules/form.js new file mode 100644 index 0000000..6496847 --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/modules/form.js @@ -0,0 +1,384 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + dialog_form_mutasi: false, + mutasi_date: moment(new Date()).format('YYYY-MM-DD'), + list_category: [], + selected_category: {}, + list_branch_asal: [], + selected_branch_asal: {}, + list_branch_tujuan: [], + selected_branch_tujuan: {}, + note: '', + dialog_select_item: false, + list_ro: [], + selected_ro: {}, + current_page: 1, + x_search: '', + total_pages: 0, + list_item_receive: [], + select_item_temp: [], + list_mutasi_item: [], + dialog_form_mutasi_verif: false, + dialog_form_mutasi_approve: false, + selected_warehouse: {}, + list_warehouse: [], + list_ruangan: [], + selected_ruangan: {} + }, + mutations: { + update_dialog_form_mutasi(state, val) { + state.dialog_form_mutasi = val; + }, + update_mutasi_date(state, val) { + state.mutasi_date = val; + }, + update_list_category(state, val) { + state.list_category = val; + }, + update_selected_category(state, val) { + state.selected_category = val; + }, + update_list_branch_asal(state, val) { + state.list_branch_asal = val; + }, + update_selected_branch_asal(state, val) { + state.selected_branch_asal = val; + }, + update_list_branch_tujuan(state, val) { + state.list_branch_tujuan = val; + }, + update_selected_branch_tujuan(state, val) { + state.selected_branch_tujuan = val; + }, + update_note(state, val) { + state.note = val; + }, + update_dialog_select_item(state, val) { + state.dialog_select_item = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_total_pages(state, val) { + state.total_pages = val; + }, + update_list_item_receive(state, val) { + state.list_item_receive = val; + }, + update_select_item_temp(state, val) { + state.select_item_temp = val; + }, + update_list_ro(state, val) { + state.list_ro = val; + }, + update_selected_ro(state, val) { + state.selected_ro = val; + }, + update_list_mutasi_item(state, val) { + state.list_mutasi_item = val; + }, + update_dialog_form_mutasi_verif(state, val) { + state.dialog_form_mutasi_verif = val + }, + update_dialog_form_mutasi_approve(state, val) { + state.dialog_form_mutasi_approve = val + }, + update_selected_warehouse(state, val) { + state.selected_warehouse = val; + }, + update_list_warehouse(state, val) { + state.list_warehouse = val; + }, + update_list_ruangan(state, val) { + state.list_ruangan = val; + }, + update_selected_ruangan(state, val) { + state.selected_ruangan = val; + } + }, + actions: { + resetForm(context) { + context.state.mutasi_date = moment(new Date()).format('YYYY-MM-DD') + context.state.selected_category = {} + context.state.selected_branch_asal = {} + context.state.selected_branch_tujuan = {} + context.state.selected_warehouse = {} + context.state.selected_ruangan = {} + context.state.note = '' + context.state.list_mutasi_item = [] + }, + + async getCategory(context) { + try { + let param = { + token: one_token(), + search: '' + } + const resp = await api.getCategory(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_category", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getBranchAsal(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getBranchAsal(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_branch_asal", resp.data.records); + context.commit("update_selected_branch_asal", resp.data.records[0]); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getBranchTujuan(context) { + try { + let param = { + token: one_token(), + branch_id: context.rootState.mutasi.selected_list_data.MutasiHandoverToBranchID + } + const resp = await api.getBranchTujuan(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_branch_tujuan", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getWarehouse(context) { + try { + let param = { + token: one_token(), + branch_id: context.rootState.mutasi.selected_list_data.MutasiHandoverToBranchID + } + const resp = await api.getWarehouse(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_warehouse", resp.data); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getRuangan(context) { + try { + let param = { + token: one_token(), + branch_id: context.rootState.mutasi.selected_list_data.MutasiHandoverToBranchID + } + const resp = await api.getRuangan(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_ruangan", resp.data); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getReceiveOrderPo(context) { + try { + let param = { + token: one_token(), + branchAsalCode: context.state.selected_branch_asal.M_BranchCode, + itemCategoryID: context.state.selected_category.itemCategoryID, + search: '', + } + const resp = await api.getReceiveOrderPo(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_ro", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getItemReceive(context) { + try { + let param = { + token: one_token(), + warhouseID: context.state.selected_ro.ReceiveOrderPoWarehouseID, + branchAsalCode: context.state.selected_ro.ReceiveOrderPoM_BranchCode, + receiveOrderPoID: context.state.selected_ro.ReceiveOrderPoID, + search: '', + current_page: context.state.current_page + } + const resp = await api.getItemReceive(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_item_receive", resp.data.records); + context.commit("update_total_pages", resp.data.total_page); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async saveMutasi(context) { + try { + let param = { + token: one_token(), + mutasi_date: context.state.mutasi_date, + category_id: context.state.selected_category.itemCategoryID, + branch_asal_id: context.state.selected_branch_asal.M_BranchID, + branch_tujuan_id: context.state.selected_branch_tujuan.M_BranchID, + note: context.state.note, + list_mutasi: context.state.list_mutasi_item + } + const resp = await api.saveMutasi(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.dispatch("resetForm"); + context.dispatch("mutasi/search", {}, {root: true}); + + context.commit("mutasi/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + + context.commit("update_dialog_form_mutasi", false); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async saveEditMutasi(context) { + try { + let param = { + token: one_token(), + mutasi_request_id: context.rootState.mutasi.selected_list_data.MutasiRequestID, + mutasi_date: context.state.mutasi_date, + category_id: context.state.selected_category.itemCategoryID, + branch_asal_id: context.state.selected_branch_asal.M_BranchID, + branch_tujuan_id: context.state.selected_branch_tujuan.M_BranchID, + note: context.state.note, + list_mutasi: context.state.list_mutasi_item + } + const resp = await api.saveEditMutasi(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.dispatch("resetForm"); + context.dispatch("mutasi/search", {}, {root: true}); + + context.commit("mutasi/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + + context.commit("update_dialog_form_mutasi_approve", false); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/modules/mutasi.js b/test/vuex/acc-one-mutasi-receive/modules/mutasi.js new file mode 100644 index 0000000..7a9d5b4 --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/modules/mutasi.js @@ -0,0 +1,300 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import mutasi from "../../acc-one-mutasi-request-approved/modules/mutasi.js"; +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + alert_error: false, + err_message: "", + menu_start_date: false, + menu_end_date: false, + d_start_date: new Date().toISOString().substring(0, 10), + d_end_date: new Date().toISOString().substring(0, 10), + f_start_date: moment(new Date()).format("YYYY-MM-DD"), + f_end_date: moment(new Date()).format("YYYY-MM-DD"), + f_status: '', + status_options: [ + { text: 'All', value: '' }, + { text: 'sent', value: 'sent' }, + { text: 'Received', value: 'Received' }, + ], + f_search : '', + list_data: [], + selected_list_data: {}, + isLoading: 0, + current_page: 1, + total_pages: 0, + snackbar: { + color: 'success', + msg: '', + isOpen: false + }, + dialog_delete: false, + approve_level: 0, + dialog_reject: false, + note_reject: '', + dialog_form_mutasi_receive: false, + dialog_form_mutasi_view: false, + dialog_barcode: false, + indeterminatex: false, + bar_chx_all: false, + barcodes: [], + urlQrCode: '', + selected_barcode: [] + }, + mutations: { + update_alert_error(state, val) { + state.alert_error = val; + }, + update_err_message(state, val) { + state.err_message = val; + }, + update_menu_start_date(state, val) { + state.menu_start_date = val; + }, + update_menu_end_date(state, val) { + state.menu_end_date = val; + }, + update_d_start_date(state, val) { + state.d_start_date = val; + }, + update_d_end_date(state, val) { + state.d_end_date = val; + }, + update_f_start_date(state, val) { + state.f_start_date = val; + }, + update_f_end_date(state, val) { + state.f_end_date = val; + }, + update_f_status(state, val) { + state.f_status = val; + }, + update_status_options(state, val) { + state.status_options = val; + }, + update_f_search(state, val) { + state.f_search = val; + state.current_page = 1 + }, + update_list_data(state, val) { + state.list_data = val; + }, + update_selected_list_data(state, val) { + state.selected_list_data = val; + }, + update_isLoading(state, val) { + state.isLoading = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_total_pages(state, val) { + state.total_pages = val; + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_dialog_delete(state, val) { + state.dialog_delete = val + }, + update_approve_level(state, data) { + state.approve_level = data + }, + update_dialog_reject(state, val) { + state.dialog_reject = val + }, + update_note_reject(state, val) { + state.note_reject = val + }, + update_dialog_form_mutasi_receive(state, val) { + state.dialog_form_mutasi_receive = val + }, + update_dialog_form_mutasi_view(state, val) { + state.dialog_form_mutasi_view = val + }, + update_dialog_barcode(state, val) { + state.dialog_barcode = val + }, + update_indeterminatex(state, val) { + state.indeterminatex = val + }, + update_bar_chx_all(state, val) { + state.bar_chx_all = val + }, + update_selected_barcode(state, val) { + state.selected_barcode = val + }, + update_barcodes(state, val) { + state.barcodes = val + }, + update_urlQrCode(state, val) { + state.urlQrCode = val + } + }, + actions: { + async search(context) { + context.commit("update_isLoading", 1) + try { + let param = { + token: one_token(), + search: context.state.f_search, + start_date: context.state.f_start_date, + end_date: context.state.f_end_date, + current_page: context.state.current_page, + status: context.state.f_status + } + const resp = await api.search(param); + if (resp.status != 'OK') { + context.commit("update_isLoading", 3) + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_isLoading", 2) + context.commit("update_list_data", resp.data.records); + context.commit("update_total_pages", resp.data.total_page); + } + } catch (error) { + context.commit("update_isLoading", 3) + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getItemDetail(context) { + try { + let param = { + token: one_token(), + mutasiHandoverID: context.state.selected_list_data.MutasiHandoverID + } + const resp = await api.getItemDetail(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("form/update_mutasi_date", context.state.selected_list_data.MutasiHandoverDate, { root: true }); + + let category = { + itemCategoryID: context.state.selected_list_data.itemCategoryID, + itemCategoryName: context.state.selected_list_data.itemCategoryName + } + context.commit("form/update_selected_category", category, { root: true }); + + let branch_asal = { + M_BranchID: context.state.selected_list_data.branch_asal_id, + M_BranchName: context.state.selected_list_data.branch_asal_name, + M_BranchCode: context.state.selected_list_data.branch_asal_code, + } + context.commit("form/update_selected_branch_asal", branch_asal, { root: true }); + + let branch_tujuan = { + M_BranchID: context.state.selected_list_data.branch_tujuan_id, + M_BranchName: context.state.selected_list_data.branch_tujuan_name, + M_BranchCode: context.state.selected_list_data.branch_tujuan_code, + } + context.commit("form/update_selected_branch_tujuan", branch_tujuan, { root: true }); + + if (context.state.selected_list_data.WarehouseID != null && context.state.selected_list_data.WarehouseID != '') { + let warehouse = { + WarehouseID: context.state.selected_list_data.WarehouseID, + WarehouseName: context.state.selected_list_data.WarehouseName + } + context.commit("form/update_selected_warehouse", warehouse, { root: true }); + } + + if (context.state.selected_list_data.M_RuanganID != null && context.state.selected_list_data.M_RuanganID != '') { + let ruangan = { + M_RuanganID: context.state.selected_list_data.M_RuanganID, + M_RuanganName: context.state.selected_list_data.M_RuanganName + } + context.commit("form/update_selected_ruangan", ruangan, { root: true }); + } + + context.commit("form/update_note", context.state.selected_list_data.MutasiHandoverNote, { root: true }); + context.commit("form/update_list_mutasi_item", resp.data.records, { root: true }); + + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async receive(context) { + try { + let param = { + token: one_token(), + mutasi_handover_id: context.state.selected_list_data.MutasiHandoverID, + warehouse_id: context.rootState.form.selected_warehouse.WarehouseID, + ruangan_id: context.rootState.form.selected_ruangan.M_RuanganID + } + const resp = await api.receive(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + + context.commit("update_dialog_form_mutasi_receive", false); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async getBarcodes(context) { + try { + let param = { + token: one_token(), + mutasi_handover_id: context.state.selected_list_data.MutasiHandoverID + } + const resp = await api.getBarcodes(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("update_barcodes", resp.data); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-receive/store.js b/test/vuex/acc-one-mutasi-receive/store.js new file mode 100644 index 0000000..e653595 --- /dev/null +++ b/test/vuex/acc-one-mutasi-receive/store.js @@ -0,0 +1,13 @@ +import mutasi from "./modules/mutasi.js"; +import form from "./modules/form.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + mutasi: mutasi, + form: form, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-mutasi-request-approved/api/api.js b/test/vuex/acc-one-mutasi-request-approved/api/api.js new file mode 100644 index 0000000..f14c3f8 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/api/api.js @@ -0,0 +1,249 @@ +const URL = "/one-api/mockup/mutasi/"; + +export async function search(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/search', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getCategory(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/getCategory', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBranchAsal(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/getBranchAsal', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBranchTujuan(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/getBranchTujuan', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getReceiveOrderPo(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/getReceiveOrderPo', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemReceive(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/getItemReceive', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveMutasi(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/saveMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemMutasiUpdate(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/getItemMutasiUpdate', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditMutasi(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/saveEditMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function deleteMutasi(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/deleteMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + + +export async function getApproveLevel(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/getApproveLevel', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function approveMutasiRequest(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/approveMutasiRequest', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function rejectMutasiRequest(params) { + try { + var resp = await axios.post(URL + 'RequestmutasiApproved/rejectMutasiRequest', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasi.vue b/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasi.vue new file mode 100644 index 0000000..f8f0ded --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasi.vue @@ -0,0 +1,307 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiApprove.vue b/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiApprove.vue new file mode 100644 index 0000000..61aabdb --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiApprove.vue @@ -0,0 +1,304 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiVerif.vue b/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiVerif.vue new file mode 100644 index 0000000..2e91a95 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiVerif.vue @@ -0,0 +1,304 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiView.vue b/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiView.vue new file mode 100644 index 0000000..ecd7aba --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/components/dialogFormMutasiView.vue @@ -0,0 +1,301 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/components/dialogNoteRejected.vue b/test/vuex/acc-one-mutasi-request-approved/components/dialogNoteRejected.vue new file mode 100644 index 0000000..f534af5 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/components/dialogNoteRejected.vue @@ -0,0 +1,78 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/components/dialogSelectItem.vue b/test/vuex/acc-one-mutasi-request-approved/components/dialogSelectItem.vue new file mode 100644 index 0000000..6063d93 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/components/dialogSelectItem.vue @@ -0,0 +1,342 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/components/mutasiListing.vue b/test/vuex/acc-one-mutasi-request-approved/components/mutasiListing.vue new file mode 100644 index 0000000..73f1944 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/components/mutasiListing.vue @@ -0,0 +1,598 @@ + + + + + diff --git a/test/vuex/acc-one-mutasi-request-approved/index.php b/test/vuex/acc-one-mutasi-request-approved/index.php new file mode 100644 index 0000000..77404c2 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/index.php @@ -0,0 +1,115 @@ + + + + + + + + + + + One + + + + + + + + + Error + + + + {{errMessage}} + + + + + + + + Tutup + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/modules/form.js b/test/vuex/acc-one-mutasi-request-approved/modules/form.js new file mode 100644 index 0000000..7547f60 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/modules/form.js @@ -0,0 +1,315 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + dialog_form_mutasi: false, + mutasi_date: moment(new Date()).format('YYYY-MM-DD'), + list_category: [], + selected_category: {}, + list_branch_asal: [], + selected_branch_asal: {}, + list_branch_tujuan: [], + selected_branch_tujuan: {}, + note: '', + dialog_select_item: false, + list_ro: [], + selected_ro: {}, + current_page: 1, + x_search: '', + total_pages: 0, + list_item_receive: [], + select_item_temp: [], + list_mutasi_item: [], + dialog_form_mutasi_verif: false, + dialog_form_mutasi_approve: false + }, + mutations: { + update_dialog_form_mutasi(state, val) { + state.dialog_form_mutasi = val; + }, + update_mutasi_date(state, val) { + state.mutasi_date = val; + }, + update_list_category(state, val) { + state.list_category = val; + }, + update_selected_category(state, val) { + state.selected_category = val; + }, + update_list_branch_asal(state, val) { + state.list_branch_asal = val; + }, + update_selected_branch_asal(state, val) { + state.selected_branch_asal = val; + }, + update_list_branch_tujuan(state, val) { + state.list_branch_tujuan = val; + }, + update_selected_branch_tujuan(state, val) { + state.selected_branch_tujuan = val; + }, + update_note(state, val) { + state.note = val; + }, + update_dialog_select_item(state, val) { + state.dialog_select_item = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_total_pages(state, val) { + state.total_pages = val; + }, + update_list_item_receive(state, val) { + state.list_item_receive = val; + }, + update_select_item_temp(state, val) { + state.select_item_temp = val; + }, + update_list_ro(state, val) { + state.list_ro = val; + }, + update_selected_ro(state, val) { + state.selected_ro = val; + }, + update_list_mutasi_item(state, val) { + state.list_mutasi_item = val; + }, + update_dialog_form_mutasi_verif(state, val) { + state.dialog_form_mutasi_verif = val + }, + update_dialog_form_mutasi_approve(state, val) { + state.dialog_form_mutasi_approve = val + } + }, + actions: { + resetForm(context) { + context.state.mutasi_date = moment(new Date()).format('YYYY-MM-DD') + context.state.selected_category = {} + context.state.selected_branch_asal = {} + context.state.selected_branch_tujuan = {} + context.state.note = '' + context.state.list_mutasi_item = [] + }, + + async getCategory(context) { + try { + let param = { + token: one_token(), + search: '' + } + const resp = await api.getCategory(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_category", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getBranchAsal(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getBranchAsal(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_branch_asal", resp.data.records); + context.commit("update_selected_branch_asal", resp.data.records[0]); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getBranchTujuan(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getBranchTujuan(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_branch_tujuan", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getReceiveOrderPo(context) { + try { + let param = { + token: one_token(), + branchAsalCode: context.state.selected_branch_asal.M_BranchCode, + itemCategoryID: context.state.selected_category.itemCategoryID, + search: '', + } + const resp = await api.getReceiveOrderPo(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_ro", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getItemReceive(context) { + try { + let param = { + token: one_token(), + warhouseID: context.state.selected_ro.ReceiveOrderPoWarehouseID, + branchAsalCode: context.state.selected_ro.ReceiveOrderPoM_BranchCode, + receiveOrderPoID: context.state.selected_ro.ReceiveOrderPoID, + search: '', + current_page: context.state.current_page + } + const resp = await api.getItemReceive(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_item_receive", resp.data.records); + context.commit("update_total_pages", resp.data.total_page); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async saveMutasi(context) { + try { + let param = { + token: one_token(), + mutasi_date: context.state.mutasi_date, + category_id: context.state.selected_category.itemCategoryID, + branch_asal_id: context.state.selected_branch_asal.M_BranchID, + branch_tujuan_id: context.state.selected_branch_tujuan.M_BranchID, + note: context.state.note, + list_mutasi: context.state.list_mutasi_item + } + const resp = await api.saveMutasi(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.dispatch("resetForm"); + context.dispatch("mutasi/search", {}, {root: true}); + + context.commit("mutasi/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + + context.commit("update_dialog_form_mutasi", false); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async saveEditMutasi(context) { + try { + let param = { + token: one_token(), + mutasi_request_id: context.rootState.mutasi.selected_list_data.MutasiRequestID, + mutasi_date: context.state.mutasi_date, + category_id: context.state.selected_category.itemCategoryID, + branch_asal_id: context.state.selected_branch_asal.M_BranchID, + branch_tujuan_id: context.state.selected_branch_tujuan.M_BranchID, + note: context.state.note, + list_mutasi: context.state.list_mutasi_item + } + const resp = await api.saveEditMutasi(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.dispatch("resetForm"); + context.dispatch("mutasi/search", {}, {root: true}); + + context.commit("mutasi/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + + context.commit("update_dialog_form_mutasi_approve", false); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/modules/mutasi.js b/test/vuex/acc-one-mutasi-request-approved/modules/mutasi.js new file mode 100644 index 0000000..7877f85 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/modules/mutasi.js @@ -0,0 +1,348 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + alert_error: false, + err_message: "", + menu_start_date: false, + menu_end_date: false, + d_start_date: new Date().toISOString().substring(0, 10), + d_end_date: new Date().toISOString().substring(0, 10), + f_start_date: moment(new Date()).format("YYYY-MM-DD"), + f_end_date: moment(new Date()).format("YYYY-MM-DD"), + f_status: '', + status_options: [ + { text: 'All', value: '' }, + { text: 'Draft', value: 'Draft' }, + { text: 'Verified', value: 'Verified' }, + { text: 'Approved', value: 'Approved' }, + { text: 'Rejected', value: 'Rejected' }, + { text: 'sent', value: 'sent' }, + { text: 'Received', value: 'Received' }, + { text: 'Done', value: 'Done' }, + ], + f_search : '', + list_data: [], + selected_list_data: {}, + isLoading: 0, + current_page: 1, + total_pages: 0, + snackbar: { + color: 'success', + msg: '', + isOpen: false + }, + dialog_delete: false, + approve_level: 0, + dialog_reject: false, + note_reject: '', + dialog_form_mutasi_view: false + }, + mutations: { + update_alert_error(state, val) { + state.alert_error = val; + }, + update_err_message(state, val) { + state.err_message = val; + }, + update_menu_start_date(state, val) { + state.menu_start_date = val; + }, + update_menu_end_date(state, val) { + state.menu_end_date = val; + }, + update_d_start_date(state, val) { + state.d_start_date = val; + }, + update_d_end_date(state, val) { + state.d_end_date = val; + }, + update_f_start_date(state, val) { + state.f_start_date = val; + }, + update_f_end_date(state, val) { + state.f_end_date = val; + }, + update_f_status(state, val) { + state.f_status = val; + }, + update_status_options(state, val) { + state.status_options = val; + }, + update_f_search(state, val) { + state.f_search = val; + state.current_page = 1 + }, + update_list_data(state, val) { + state.list_data = val; + }, + update_selected_list_data(state, val) { + state.selected_list_data = val; + }, + update_isLoading(state, val) { + state.isLoading = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_total_pages(state, val) { + state.total_pages = val; + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_dialog_delete(state, val) { + state.dialog_delete = val + }, + update_approve_level(state, data) { + state.approve_level = data + }, + update_dialog_reject(state, val) { + state.dialog_reject = val + }, + update_note_reject(state, val) { + state.note_reject = val + }, + update_dialog_form_mutasi_view(state, val) { + state.dialog_form_mutasi_view = val + } + }, + actions: { + async search(context) { + context.commit("update_isLoading", 1) + try { + let param = { + token: one_token(), + search: context.state.f_search, + start_date: context.state.f_start_date, + end_date: context.state.f_end_date, + current_page: context.state.current_page, + status: context.state.f_status + } + const resp = await api.search(param); + if (resp.status != 'OK') { + context.commit("update_isLoading", 3) + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_isLoading", 2) + context.commit("update_list_data", resp.data.records); + context.commit("update_total_pages", resp.data.total_page); + } + } catch (error) { + context.commit("update_isLoading", 3) + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getItemMutasiUpdate(context) { + try { + let param = { + token: one_token(), + mutasiRequestID: context.state.selected_list_data.MutasiRequestID + } + const resp = await api.getItemMutasiUpdate(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("form/update_mutasi_date", context.state.selected_list_data.MutasiRequestDate, { root: true }); + + let category = { + itemCategoryID: context.state.selected_list_data.itemCategoryID, + itemCategoryName: context.state.selected_list_data.itemCategoryName + } + context.commit("form/update_selected_category", category, { root: true }); + + let branch_asal = { + M_BranchID: context.state.selected_list_data.branch_asal_id, + M_BranchName: context.state.selected_list_data.branch_asal_name, + M_BranchCode: context.state.selected_list_data.branch_asal_code, + } + context.commit("form/update_selected_branch_asal", branch_asal, { root: true }); + + let branch_tujuan = { + M_BranchID: context.state.selected_list_data.branch_tujuan_id, + M_BranchName: context.state.selected_list_data.branch_tujuan_name, + M_BranchCode: context.state.selected_list_data.branch_tujuan_code, + } + context.commit("form/update_selected_branch_tujuan", branch_tujuan, { root: true }); + + context.commit("form/update_note", context.state.selected_list_data.MutasiRequestNote, { root: true }); + context.commit("form/update_list_mutasi_item", resp.data.records, { root: true }); + + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async deleteMutasi(context) { + try { + let param = { + token: one_token(), + mutasiRequestID: context.state.selected_list_data.MutasiRequestID + } + const resp = await api.deleteMutasi(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit('update_dialog_delete', false) + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async getApproveLevel(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getApproveLevel(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + let data = resp.data.M_UserM_ApproveLevelID + + context.commit("update_approve_level", data) + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async verifMutasiRequest(context, param) { + try { + param.token = one_token() + param.approvelevel = context.state.approve_level + const resp = await api.approveMutasiRequest(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit("form/update_dialog_form_mutasi_verif", false, { root: true }); + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async approveMutasiRequest(context, param) { + try { + param.token = one_token() + param.approvelevel = context.state.approve_level + const resp = await api.approveMutasiRequest(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit("form/update_dialog_form_mutasi_approve", false, { root: true }); + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async rejectMutasiRequest(context, param) { + try { + param.token = one_token() + const resp = await api.rejectMutasiRequest(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit("update_dialog_reject", false); + context.commit("update_note_reject", ''); + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request-approved/store.js b/test/vuex/acc-one-mutasi-request-approved/store.js new file mode 100644 index 0000000..e653595 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request-approved/store.js @@ -0,0 +1,13 @@ +import mutasi from "./modules/mutasi.js"; +import form from "./modules/form.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + mutasi: mutasi, + form: form, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-mutasi-request/api/api.js b/test/vuex/acc-one-mutasi-request/api/api.js new file mode 100644 index 0000000..33e15a0 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/api/api.js @@ -0,0 +1,191 @@ +const URL = "/one-api/mockup/mutasi/"; + +export async function search(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/search', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getCategory(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/getCategory', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBranchAsal(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/getBranchAsal', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getBranchTujuan(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/getBranchTujuan', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getReceiveOrderPo(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/getReceiveOrderPo', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemReceive(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/getItemReceive', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveMutasi(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/saveMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemMutasiUpdate(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/getItemMutasiUpdate', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditMutasi(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/saveEditMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function deleteMutasi(params) { + try { + var resp = await axios.post(URL + 'Requestmutasi/deleteMutasi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-mutasi-request/components/dialogFormMutasi.vue b/test/vuex/acc-one-mutasi-request/components/dialogFormMutasi.vue new file mode 100644 index 0000000..c95d3bf --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/components/dialogFormMutasi.vue @@ -0,0 +1,310 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request/components/dialogFormMutasiEdit.vue b/test/vuex/acc-one-mutasi-request/components/dialogFormMutasiEdit.vue new file mode 100644 index 0000000..eea0419 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/components/dialogFormMutasiEdit.vue @@ -0,0 +1,307 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request/components/dialogRmLayout.vue b/test/vuex/acc-one-mutasi-request/components/dialogRmLayout.vue new file mode 100644 index 0000000..6f568f7 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/components/dialogRmLayout.vue @@ -0,0 +1,59 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request/components/dialogSelectItem.vue b/test/vuex/acc-one-mutasi-request/components/dialogSelectItem.vue new file mode 100644 index 0000000..0c2d34e --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/components/dialogSelectItem.vue @@ -0,0 +1,350 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request/components/mutasiListing.vue b/test/vuex/acc-one-mutasi-request/components/mutasiListing.vue new file mode 100644 index 0000000..a925a13 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/components/mutasiListing.vue @@ -0,0 +1,552 @@ + + + + + diff --git a/test/vuex/acc-one-mutasi-request/index.php b/test/vuex/acc-one-mutasi-request/index.php new file mode 100644 index 0000000..77404c2 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/index.php @@ -0,0 +1,115 @@ + + + + + + + + + + + One + + + + + + + + + Error + + + + {{errMessage}} + + + + + + + + Tutup + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request/modules/form.js b/test/vuex/acc-one-mutasi-request/modules/form.js new file mode 100644 index 0000000..51dc51b --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/modules/form.js @@ -0,0 +1,311 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + dialog_form_mutasi: false, + mutasi_date: moment(new Date()).format('YYYY-MM-DD'), + list_category: [], + selected_category: {}, + list_branch_asal: [], + selected_branch_asal: {}, + list_branch_tujuan: [], + selected_branch_tujuan: {}, + note: '', + dialog_select_item: false, + list_ro: [], + selected_ro: {}, + current_page: 1, + x_search: '', + total_pages: 0, + list_item_receive: [], + select_item_temp: [], + list_mutasi_item: [], + dialog_form_mutasi_edit: false + }, + mutations: { + update_dialog_form_mutasi(state, val) { + state.dialog_form_mutasi = val; + }, + update_mutasi_date(state, val) { + state.mutasi_date = val; + }, + update_list_category(state, val) { + state.list_category = val; + }, + update_selected_category(state, val) { + state.selected_category = val; + }, + update_list_branch_asal(state, val) { + state.list_branch_asal = val; + }, + update_selected_branch_asal(state, val) { + state.selected_branch_asal = val; + }, + update_list_branch_tujuan(state, val) { + state.list_branch_tujuan = val; + }, + update_selected_branch_tujuan(state, val) { + state.selected_branch_tujuan = val; + }, + update_note(state, val) { + state.note = val; + }, + update_dialog_select_item(state, val) { + state.dialog_select_item = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_total_pages(state, val) { + state.total_pages = val; + }, + update_list_item_receive(state, val) { + state.list_item_receive = val; + }, + update_select_item_temp(state, val) { + state.select_item_temp = val; + }, + update_list_ro(state, val) { + state.list_ro = val; + }, + update_selected_ro(state, val) { + state.selected_ro = val; + }, + update_list_mutasi_item(state, val) { + state.list_mutasi_item = val; + }, + update_dialog_form_mutasi_edit(state, val) { + state.dialog_form_mutasi_edit = val + } + }, + actions: { + resetForm(context) { + context.state.mutasi_date = moment(new Date()).format('YYYY-MM-DD') + context.state.selected_category = {} + context.state.selected_branch_asal = {} + context.state.selected_branch_tujuan = {} + context.state.note = '' + context.state.list_mutasi_item = [] + }, + + async getCategory(context) { + try { + let param = { + token: one_token(), + search: '' + } + const resp = await api.getCategory(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_category", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getBranchAsal(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getBranchAsal(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_branch_asal", resp.data.records); + context.commit("update_selected_branch_asal", resp.data.records[0]); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getBranchTujuan(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getBranchTujuan(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_branch_tujuan", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getReceiveOrderPo(context) { + try { + let param = { + token: one_token(), + branchAsalCode: context.state.selected_branch_asal.M_BranchCode, + itemCategoryID: context.state.selected_category.itemCategoryID, + search: '', + } + const resp = await api.getReceiveOrderPo(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_ro", resp.data.records); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getItemReceive(context) { + try { + let param = { + token: one_token(), + warhouseID: context.state.selected_ro.ReceiveOrderPoWarehouseID, + branchAsalCode: context.state.selected_ro.ReceiveOrderPoM_BranchCode, + receiveOrderPoID: context.state.selected_ro.ReceiveOrderPoID, + search: '', + current_page: context.state.current_page + } + const resp = await api.getItemReceive(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_list_item_receive", resp.data.records); + context.commit("update_total_pages", resp.data.total_page); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async saveMutasi(context) { + try { + let param = { + token: one_token(), + mutasi_date: context.state.mutasi_date, + category_id: context.state.selected_category.itemCategoryID, + branch_asal_id: context.state.selected_branch_asal.M_BranchID, + branch_tujuan_id: context.state.selected_branch_tujuan.M_BranchID, + note: context.state.note, + list_mutasi: context.state.list_mutasi_item + } + const resp = await api.saveMutasi(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.dispatch("resetForm"); + context.dispatch("mutasi/search", {}, {root: true}); + + context.commit("mutasi/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + + context.commit("update_dialog_form_mutasi", false); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async saveEditMutasi(context) { + try { + let param = { + token: one_token(), + mutasi_request_id: context.rootState.mutasi.selected_list_data.MutasiRequestID, + mutasi_date: context.state.mutasi_date, + category_id: context.state.selected_category.itemCategoryID, + branch_asal_id: context.state.selected_branch_asal.M_BranchID, + branch_tujuan_id: context.state.selected_branch_tujuan.M_BranchID, + note: context.state.note, + list_mutasi: context.state.list_mutasi_item + } + const resp = await api.saveEditMutasi(param); + if (resp.status != 'OK') { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.dispatch("resetForm"); + context.dispatch("mutasi/search", {}, {root: true}); + + context.commit("mutasi/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + + context.commit("update_dialog_form_mutasi_edit", false); + } + } catch (error) { + context.commit("mutasi/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request/modules/mutasi.js b/test/vuex/acc-one-mutasi-request/modules/mutasi.js new file mode 100644 index 0000000..a5a5de4 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/modules/mutasi.js @@ -0,0 +1,216 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + alert_error: false, + err_message: "", + menu_start_date: false, + menu_end_date: false, + d_start_date: new Date().toISOString().substring(0, 10), + d_end_date: new Date().toISOString().substring(0, 10), + f_start_date: moment(new Date()).format("YYYY-MM-DD"), + f_end_date: moment(new Date()).format("YYYY-MM-DD"), + f_status: '', + status_options: [ + { text: 'All', value: '' }, + { text: 'Draft', value: 'Draft' }, + { text: 'Verified', value: 'Verified' }, + { text: 'Approved', value: 'Approved' }, + { text: 'Rejected', value: 'Rejected' }, + { text: 'sent', value: 'sent' }, + { text: 'Received', value: 'Received' }, + { text: 'Done', value: 'Done' }, + ], + f_search : '', + list_data: [], + selected_list_data: {}, + isLoading: 0, + current_page: 1, + total_pages: 0, + snackbar: { + color: 'success', + msg: '', + isOpen: false + }, + dialog_delete: false + }, + mutations: { + update_alert_error(state, val) { + state.alert_error = val; + }, + update_err_message(state, val) { + state.err_message = val; + }, + update_menu_start_date(state, val) { + state.menu_start_date = val; + }, + update_menu_end_date(state, val) { + state.menu_end_date = val; + }, + update_d_start_date(state, val) { + state.d_start_date = val; + }, + update_d_end_date(state, val) { + state.d_end_date = val; + }, + update_f_start_date(state, val) { + state.f_start_date = val; + }, + update_f_end_date(state, val) { + state.f_end_date = val; + }, + update_f_status(state, val) { + state.f_status = val; + }, + update_status_options(state, val) { + state.status_options = val; + }, + update_f_search(state, val) { + state.f_search = val; + state.current_page = 1 + }, + update_list_data(state, val) { + state.list_data = val; + }, + update_selected_list_data(state, val) { + state.selected_list_data = val; + }, + update_isLoading(state, val) { + state.isLoading = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_total_pages(state, val) { + state.total_pages = val; + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_dialog_delete(state, val) { + state.dialog_delete = val + } + }, + actions: { + async search(context) { + context.commit("update_isLoading", 1) + try { + let param = { + token: one_token(), + search: context.state.f_search, + start_date: context.state.f_start_date, + end_date: context.state.f_end_date, + current_page: context.state.current_page, + status: context.state.f_status + } + const resp = await api.search(param); + if (resp.status != 'OK') { + context.commit("update_isLoading", 3) + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, { root: true }); + } else { + context.commit("update_isLoading", 2) + context.commit("update_list_data", resp.data.records); + context.commit("update_total_pages", resp.data.total_page); + } + } catch (error) { + context.commit("update_isLoading", 3) + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, { root: true }); + } + }, + + async getItemMutasiUpdate(context) { + try { + let param = { + token: one_token(), + mutasiRequestID: context.state.selected_list_data.MutasiRequestID + } + const resp = await api.getItemMutasiUpdate(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("form/update_mutasi_date", context.state.selected_list_data.MutasiRequestDate, { root: true }); + + let category = { + itemCategoryID: context.state.selected_list_data.itemCategoryID, + itemCategoryName: context.state.selected_list_data.itemCategoryName + } + context.commit("form/update_selected_category", category, { root: true }); + + let branch_asal = { + M_BranchID: context.state.selected_list_data.branch_asal_id, + M_BranchName: context.state.selected_list_data.branch_asal_name, + M_BranchCode: context.state.selected_list_data.branch_asal_code, + } + context.commit("form/update_selected_branch_asal", branch_asal, { root: true }); + + let branch_tujuan = { + M_BranchID: context.state.selected_list_data.branch_tujuan_id, + M_BranchName: context.state.selected_list_data.branch_tujuan_name, + M_BranchCode: context.state.selected_list_data.branch_tujuan_code, + } + context.commit("form/update_selected_branch_tujuan", branch_tujuan, { root: true }); + + context.commit("form/update_note", context.state.selected_list_data.MutasiRequestNote, { root: true }); + context.commit("form/update_list_mutasi_item", resp.data.records, { root: true }); + + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + async deleteMutasi(context) { + try { + let param = { + token: one_token(), + mutasiRequestID: context.state.selected_list_data.MutasiRequestID + } + const resp = await api.deleteMutasi(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.dispatch("search"); + context.commit('update_dialog_delete', false) + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-mutasi-request/store.js b/test/vuex/acc-one-mutasi-request/store.js new file mode 100644 index 0000000..e653595 --- /dev/null +++ b/test/vuex/acc-one-mutasi-request/store.js @@ -0,0 +1,13 @@ +import mutasi from "./modules/mutasi.js"; +import form from "./modules/form.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + mutasi: mutasi, + form: form, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-payment-receive-v2/api/journal.js b/test/vuex/acc-one-payment-receive-v2/api/journal.js new file mode 100644 index 0000000..8c58954 --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/api/journal.js @@ -0,0 +1,324 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + "Journalarpaymentv2/getPeriode", prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search( + token, + xdate, + periodeid, + current_page, + search, + branchCode, + regionalId +) { + try { + var resp = await axios.post(URL + "Journalarpaymentv2/search", { + token: token, + xdate: xdate, + periodeid: periodeid, + current_page: current_page, + search: search, + branchCode: branchCode, + regionalId: regionalId + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertArPayment(branchCode, date, jurnalID) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertArPayment/${branchCode}/${date}/1/${jurnalID}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertRkTagihan(branchCode, date, jurnalID) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertRkTagihan/${branchCode}/${date}/1/${jurnalID}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertRkPelunasan(branchCode, date, jurnalID) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertRkPelunasan/${branchCode}/${date}/1/${jurnalID}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "Journalarpaymentv2/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "Journalarpaymentv2/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + "Journalarpaymentv2/getUserApproveLevel", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListingCOA(params) { + try { + var resp = await axios.post(URL + "Journalarpaymentv2/getListingCOA", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function requestEditJurnal(params) { + try { + const resp = await axios.post(URL + "JournalVerifEdit/requestEditJurnal", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + const data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditJurnal(params) { + try { + var resp = await axios.post(URL + "JournalVerifEdit/saveEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function changeJurnalToPosted(params) { + try { + var resp = await axios.post(URL + "Journalarpaymentv2/changeJurnalToPosted", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getTotalJurnalNotPostedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journalarpaymentv2/getTotalJurnalNotPostedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function closeJurnalPerPeriode(params) { + try { + var resp = await axios.post(URL + "Journalarpaymentv2/closeJurnalPerPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataJurnalNotClosedPerPeriod(params) { + try { + var resp = await axios.post( + URL + "Journalarpaymentv2/getDataJurnalNotClosedPerPeriod", + params + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-payment-receive-v2/components/dialogCloseJurnal.vue b/test/vuex/acc-one-payment-receive-v2/components/dialogCloseJurnal.vue new file mode 100644 index 0000000..417ffbb --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/components/dialogCloseJurnal.vue @@ -0,0 +1,76 @@ + + + diff --git a/test/vuex/acc-one-payment-receive-v2/components/dialogEditJurnal.vue b/test/vuex/acc-one-payment-receive-v2/components/dialogEditJurnal.vue new file mode 100644 index 0000000..20ab29c --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/components/dialogEditJurnal.vue @@ -0,0 +1,223 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-payment-receive-v2/components/dialogPostingJurnal.vue b/test/vuex/acc-one-payment-receive-v2/components/dialogPostingJurnal.vue new file mode 100644 index 0000000..0ae425c --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/components/dialogPostingJurnal.vue @@ -0,0 +1,68 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-payment-receive-v2/components/dialogRequestEditJurnal.vue b/test/vuex/acc-one-payment-receive-v2/components/dialogRequestEditJurnal.vue new file mode 100644 index 0000000..92715a8 --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/components/dialogRequestEditJurnal.vue @@ -0,0 +1,58 @@ + + + diff --git a/test/vuex/acc-one-payment-receive-v2/components/oneMediaJournalList.vue b/test/vuex/acc-one-payment-receive-v2/components/oneMediaJournalList.vue new file mode 100644 index 0000000..c4e2596 --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/components/oneMediaJournalList.vue @@ -0,0 +1,1278 @@ + + + + + diff --git a/test/vuex/acc-one-payment-receive-v2/index.php b/test/vuex/acc-one-payment-receive-v2/index.php new file mode 100644 index 0000000..a736dd6 --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-payment-receive-v2/modules/journal.js b/test/vuex/acc-one-payment-receive-v2/modules/journal.js new file mode 100644 index 0000000..4bede61 --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/modules/journal.js @@ -0,0 +1,658 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js"; + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: "new", + save_status: 0, + save_error_message: "", + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format("YYYY-MM-DD"), + end_date: moment(new Date()).format("YYYY-MM-DD"), + journals: [], + selected_journal: {}, + summary: {}, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + autocomplete_status: 0, + search_status: 0, + total_journal: 0, + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: "", + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + xsearch: "", + user: one_user(), + open_dialog_info: false, + msg_info: "", + + // -- + dialog_edit_journal: false, + user_level: {}, + list_coa: [], + journal_edit: [], + dialog_confirm_posting: false, + total_jurnal_not_posted: [], + dialog_request_edit: false, + + // --- + dialog_close_jurnal: false, + jurnal_to_close: [] + }, + mutations: { + update_search_status(state, val) { + state.search_status = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_last_id(state, val) { + state.last_id = val; + }, + update_coas(state, val) { + state.coas = val; + }, + update_total_coas(state, val) { + state.total_coas = val; + }, + update_selected_coa(state, val) { + state.selected_coa = val; + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val; + }, + update_act(state, val) { + state.act = val; + }, + update_save_status(state, val) { + state.save_status = val; + }, + update_save_error_message(state, val) { + state.save_error_message = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_msg_success(state, val) { + state.msg_success = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_dialog_error(state, val) { + state.dialog_error = val; + }, + update_open_print(state, value) { + state.open_print = value; + }, + + // --- + update_xdate(state, val) { + state.xdate = val; + }, + update_end_date(state, val) { + state.end_date = val; + }, + update_journals(state, val) { + state.journals = val; + }, + update_selected_journal(state, val) { + state.selected_journal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val; + }, + update_periodeList(state, val) { + state.periodeList = val; + }, + update_selected_periode(state, val) { + state.selected_periode = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val; + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_total_journal(state, val) { + state.total_journal = val; + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val; + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val; + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val; + }, + update_regionals(state, val) { + state.regionals = val; + }, + update_selected_regional(state, val) { + state.selected_regional = val; + }, + update_branchs(state, val) { + state.branchs = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.current_page = 1; + }, + update_user(state, val) { + state.user = val; + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val; + }, + update_msg_info(state, val) { + state.msg_info = val; + }, + + update_dialog_edit_journal(state, val) { + state.dialog_edit_journal = val; + }, + update_user_level(state, val) { + state.user_level = val; + }, + update_list_coa(state, val) { + state.list_coa = val; + }, + update_journal_edit(state, val) { + state.journal_edit = val; + }, + update_dialog_confirm_posting(state, val) { + state.dialog_confirm_posting = val; + }, + update_total_jurnal_not_posted(state, val) { + state.total_jurnal_not_posted = val; + }, + update_dialog_request_edit(state, val) { + state.dialog_request_edit = val; + }, + + update_dialog_close_jurnal(state, val) { + state.dialog_close_jurnal = val; + }, + update_jurnal_to_close(state, val) { + state.jurnal_to_close = val; + } + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1); + try { + let prm = {}; + prm.token = one_token(); + let resp = await api.getPeriode(prm); + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_autocomplete_status", 2); + let data = resp.data; + context.commit("update_periodeList", resp.data); + + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find( + (p) => + p.periodeMonth == currentMonth.toString() && + p.periodeYear == currentYear + ); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode); + } + } catch (e) { + context.commit("update_autocomplete_status", 3); + } + }, + async search(context, prm) { + context.commit("update_search_status", 1); + try { + let resp = await api.search( + one_token(), + prm.xdate, + prm.periodeid, + prm.current_page, + prm.search, + prm.branchCode, + prm.regionalId + ); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total + }; + + context.commit("update_journals", data.records); + context.commit("update_total_journal", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async insertArPayment(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalID = prm.jurnalID; + let resp = await api.insertArPayment(branchCode, date, jurnalID); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + branchCode: prm.branchCode, + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async insertRkTagihan(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalID = prm.jurnalID; + let resp = await api.insertRkTagihan(branchCode, date, jurnalID); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + branchCode: prm.branchCode, + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async insertRkPelunasan(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalID = prm.jurnalID; + let resp = await api.insertRkPelunasan(branchCode, date, jurnalID); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + branchCode: prm.branchCode, + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getRegional(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getRegional({ + token: one_token(), + regionalId: context.state.user.S_RegionalID + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_regionals", data.records); + context.commit("update_selected_regional", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async getBranch(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getBranch({ + token: one_token(), + regionalId: context.state.selected_regional.S_RegionalID, + branchCode: context.state.user.M_BranchCode + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_branchs", data.records); + context.commit("update_selected_branch", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async postingJurnal(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.changeJurnalToPosted(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_total_jurnal_not_posted", []); + context.commit("update_dialog_confirm_posting", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getUserApprovalLevel(context) { + try { + let param = { token: one_token() }; + const resp = await api.getUserApproveLevel(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getListingCOA(context) { + try { + let param = { + token: one_token(), + keyword: "" + }; + const resp = await api.getListingCOA(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_list_coa", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async requestEditJurnal(context) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + staffID: context.state.user.M_UserID, + staffName: context.state.user.M_UserUsername + }; + const resp = await api.requestEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + context.commit("update_dialog_request_edit", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async saveEditJurnal(context, newdetail) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + jurnalRequestEditID: context.state.selected_journal.JurnalRequestEditID, + oldjurnaltx: context.state.selected_journal.detailtx, + newjurnaltx: newdetail + }; + const resp = await api.saveEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_dialog_edit_journal", false); + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async totalJurnalNotPostedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getTotalJurnalNotPostedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_total_jurnal_not_posted", resp.data.total_jurnal ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getDataJurnalNotClosedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getDataJurnalNotClosedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_jurnal_to_close", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async closeJurnalPerPeriode(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.closeJurnalPerPeriode(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_jurnal_to_close", []); + context.commit("update_dialog_close_jurnal", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + } + } +}; diff --git a/test/vuex/acc-one-payment-receive-v2/store.js b/test/vuex/acc-one-payment-receive-v2/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-payment-receive-v2/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-payment-voucher/api/voucher.js b/test/vuex/acc-one-payment-voucher/api/voucher.js new file mode 100644 index 0000000..4a7f006 --- /dev/null +++ b/test/vuex/acc-one-payment-voucher/api/voucher.js @@ -0,0 +1,344 @@ +const URL = "/one-api/mockup/purchase/cashier/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/search", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchBranch(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getbranch',{ + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchAccDana(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getcoa', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchAccBiaya(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getcoa', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchAccTemp(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getcoa', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getPurchase(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/getPurchase", { + token: token, + branchcode: prm, + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchdetail(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/searchdetail", { + token: token, + ID: prm, + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveDetail(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/save", { + token: token, + BranchCode: prm.branch, + CoaSourceID: prm.accountDana, + CoaExpenseID: prm.accountBiaya, + CoaTemporaryID: prm.accountTemp, + total: prm.total, + details: prm.details + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getTotalApproved(token) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/getTotalApproved', { + token: token + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteVoucher(token, prm) { + try { + var resp = await axios.post(URL + 'purchaseRequestDirect/delete', { + token: token, + ID: prm.PVID + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editVoucher(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/update", { + token: token, + BranchCode: prm.branch, + CoaSourceID: prm.accountDana, + CoaExpenseID: prm.accountBiaya, + CoaTemporaryID: prm.accountTemp, + total: prm.total, + details: prm.details, + ID: prm.voucherID + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getPurchaseUpdateNew(token, prm) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/getPurchaseUpdateNew", { + token: token, + branchcode: prm.branchcode, + ID: prm.voucherID + } + ); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getVoucherDetailItem(params) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/voucherDetailItem", params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message, + }; + } +} + +export async function saveAccountItem(params) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/saveAccountDetail", params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText, + }; + } + + let data = resp.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message, + }; + } +} + +export async function moveToKasir(param) { + try { + var resp = await axios.post(URL + "purchaseRequestDirect/moveToKasir", param) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } else { + let data = resp.data + return data + } + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-payment-voucher/components/dialogAccountItem.vue b/test/vuex/acc-one-payment-voucher/components/dialogAccountItem.vue new file mode 100644 index 0000000..983da24 --- /dev/null +++ b/test/vuex/acc-one-payment-voucher/components/dialogAccountItem.vue @@ -0,0 +1,101 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-payment-voucher/components/dialogFormVoucher.vue b/test/vuex/acc-one-payment-voucher/components/dialogFormVoucher.vue new file mode 100644 index 0000000..a4bb290 --- /dev/null +++ b/test/vuex/acc-one-payment-voucher/components/dialogFormVoucher.vue @@ -0,0 +1,524 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-payment-voucher/components/voucherListing.vue b/test/vuex/acc-one-payment-voucher/components/voucherListing.vue new file mode 100644 index 0000000..faf9683 --- /dev/null +++ b/test/vuex/acc-one-payment-voucher/components/voucherListing.vue @@ -0,0 +1,590 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-payment-voucher/components/voucherListingDetail.vue b/test/vuex/acc-one-payment-voucher/components/voucherListingDetail.vue new file mode 100644 index 0000000..f0c7373 --- /dev/null +++ b/test/vuex/acc-one-payment-voucher/components/voucherListingDetail.vue @@ -0,0 +1,259 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-payment-voucher/index.php b/test/vuex/acc-one-payment-voucher/index.php new file mode 100644 index 0000000..3b8297a --- /dev/null +++ b/test/vuex/acc-one-payment-voucher/index.php @@ -0,0 +1,71 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-payment-voucher/modules/voucher.js b/test/vuex/acc-one-payment-voucher/modules/voucher.js new file mode 100644 index 0000000..d0c7420 --- /dev/null +++ b/test/vuex/acc-one-payment-voucher/modules/voucher.js @@ -0,0 +1,628 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/voucher.js"; + +export default { + namespaced: true, + state: { + dialog_voucher: false, + status_options: [ + { val: 0, text: 'All' }, { val: 1, text: 'Draft' }, + { val: 2, text: 'Paid' }, { val: 3, text: 'Realitation' } + ], + selected_status: { val: 1, text: 'Draft' }, + menuStartDate: false, + menuEndDate: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + xStartDate: moment(new Date()).format('YYYY-MM-DD'), + xEndDate: moment(new Date()).format('YYYY-MM-DD'), + + // listing + currentPage: 1, + search_status: 0, + search_error_message: "", + voucherList: [], + selected_voucher: {}, + total_page_voucher: 0, + xsearch: "", + act: "new", + + // form + load_status_branch: 0, + error_message: "", + alert_error: false, + branchList: [], + selected_branch: {}, + search_branch: "", + accountDanaList: [], + selected_accountDana: {}, + search_accountDana: "", + load_status_accDana: 0, + accountBiayaList: [], + selected_accountBiaya: {}, + search_accountBiaya: "", + load_status_accBiaya: 0, + accountTempList: [], + selected_accountTemp: {}, + search_accountTemp: "", + load_status_accTemp: 0, + load_status: 0, + purchaseList: [], + selected_purchase: [], + resume_total: {"totalRealitation": 0}, + errors: [], + alert_error: false, + alert_success: false, + success_message: "", + totalApproved: 0, + + // detail + search_status_detail: 0, + details: [], + + // add coa per item + dialog_account_item: false, + list_voucher_detail: [], + list_accitem: [] + }, + mutations: { + update_dialog_voucher(state, val) { + state.dialog_voucher = val; + }, + update_status_options(state, val) { + state.status_options = val; + }, + update_selected_status(state, val) { + state.selected_status = val; + }, + update_menuStartDate(state, val) { + state.menuStartDate = val; + }, + update_menuEndDate(state, val) { + state.menuEndDate = val; + }, + update_dStartDate(state, val) { + state.dStartDate = val; + }, + update_dEndDate(state, val) { + state.dEndDate = val; + }, + update_xStartDate(state, val) { + state.xStartDate = val; + }, + update_xEndDate(state, val) { + state.xEndDate = val; + }, + update_currentPage(state, val) { + state.currentPage = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_voucherList(state, val) { + state.voucherList = val; + }, + update_selected_voucher(state, val) { + state.selected_voucher = val; + }, + update_total_page_voucher(state, val) { + state.total_page_voucher = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.currentPage = 1; + }, + update_act(state, val) { + state.act = val + }, + update_load_status_branch(state, val) { + state.load_status_branch = val; + }, + update_error_message(state, val) { + state.error_message = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_branchList(state, val) { + state.branchList = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_search_branch(state, val) { + state.search_branch = val; + }, + update_accountDanaList(state, val) { + state.accountDanaList = val; + }, + update_selected_accountDana(state, val) { + state.selected_accountDana = val; + }, + update_search_accountDana(state, val) { + state.search_accountDana = val; + }, + update_load_status_accDana(state, val) { + state.load_status_accDana = val; + }, + update_accountBiayaList(state, val) { + state.accountBiayaList = val; + }, + update_selected_accountBiaya(state, val) { + state.selected_accountBiaya = val; + }, + update_search_accountBiaya(state, val) { + state.search_accountBiaya = val; + }, + update_load_status_accBiaya(state, val) { + state.load_status_accBiaya = val; + }, + update_accountTempList(state, val) { + state.accountTempList = val; + }, + update_selected_accountTemp(state, val) { + state.selected_accountTemp = val; + }, + update_search_accountTemp(state, val) { + state.search_accountTemp = val; + }, + update_load_status_accTemp(state, val) { + state.load_status_accTemp = val; + }, + update_load_status(state, val) { + state.load_status = val; + }, + update_purchaseList(state, val) { + state.purchaseList = val; + }, + update_selected_purchase(state, val) { + state.selected_purchase = val; + }, + update_resume_total(state, val) { + state.resume_total = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_success_message(state, val) { + state.success_message = val; + }, + update_totalApproved(state, val) { + state.totalApproved = val + }, + update_search_status_detail(state, val) { + state.search_status_detail = val; + }, + update_details(state, val) { + state.details = val + }, + update_dialog_account_item(state, val) { + state.dialog_account_item = val + }, + update_list_voucher_detail(state, val) { + state.list_voucher_detail = val + }, + update_list_accitem(state, val) { + state.list_accitem = val + } + }, + actions: { + async search(context) { + context.commit("update_search_status", 1); + + try { + var prm = { + token: one_token(), + currentPage: context.state.currentPage, + status: context.state.selected_status.text, + search: context.state.xsearch, + startdate: context.state.xStartDate, + enddate: context.state.xEndDate, + lastId: -1, + }; + + let resp = await api.search(prm); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total, + }; + + context.commit("update_voucherList", data.records); + context.commit("update_total_page_voucher", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async searchBranch(context, prm) { + context.commit("update_load_status_branch", 1) + try { + let resp = await api.searchBranch(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status_branch", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status_branch", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_branchList", data.records) + } + } catch (e) { + context.commit("update_load_status_branch", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async searchAccDana(context, prm) { + context.commit("update_load_status_accDana", 1) + try { + let resp = await api.searchAccDana(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status_accDana", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status_accDana", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_accountDanaList", data.records) + } + } catch (e) { + context.commit("update_load_status_accDana", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async searchAccBiaya(context, prm) { + context.commit("update_load_status_accBiaya", 1) + try { + let resp = await api.searchAccBiaya(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status_accBiaya", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status_accBiaya", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_accountBiayaList", data.records) + } + } catch (e) { + context.commit("update_load_status_accBiaya", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async searchAccTemp(context, prm) { + context.commit("update_load_status_accTemp", 1) + try { + let resp = await api.searchAccTemp(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status_accTemp", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status_accTemp", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_accountTempList", data.records) + } + } catch (e) { + context.commit("update_load_status_accTemp", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getPurchase(context, prm) { + context.commit("update_load_status", 1) + try { + let resp = await api.getPurchase(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_purchaseList", data.records) + } + } catch (e) { + context.commit("update_load_status", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async searchdetail(context, prm) { + context.commit("update_search_status_detail", 1) + try { + let resp = await api.searchdetail(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status_detail", 3) + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status_detail", 2) + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_details", data.records) + } + } catch (e) { + context.commit("update_search_status_detail", 3) + context.commit("update_search_error_message", e.message); + } + }, + + async save(context, prm) { + context.commit("update_search_status_detail", 1) + try { + + let resp = await api.saveDetail(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_search_status_detail", 2) + context.commit("update_error_message", resp.message); + + let data = { + records: resp.data.records + } + + context.commit("update_alert_success", true); + context.commit("update_dialog_voucher", false); + var msg = `Sukses menyimpan data baru dengan kode ${data.records[0].PaymentVoucherNumber}`; + context.commit("update_success_message", msg); + context.commit("update_selected_voucher", data.records[0]); + context.dispatch("search"); + context.dispatch("searchdetail", data.records[0].PaymentVoucherID); + } + } catch (e) { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getTotalApproved(context, prm) { + context.commit("update_search_status", 1) + try { + let resp = await api.getTotalApproved(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_error_message", resp.message); + } else { + context.commit("update_search_status", 2) + context.commit("update_error_message", ""); + let data = { + total: resp.data.total + } + + context.commit("update_totalApproved", data.total) + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_error_message", e.message); + } + }, + + async delete(context, prm) { + context.commit("update_search_status", 1) + try { + + let resp = await api.deleteVoucher(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_search_status", 2) + context.commit("update_error_message", resp.message); + + let data = { + records: resp.data.records + } + + context.commit("update_alert_success", true); + context.commit("update_dialog_voucher", false); + var msg = `Sukses menghapus data dengan kode ` + prm.PVNumber; + context.commit("update_success_message", msg); + // context.commit("update_selected_voucher", data.records[0]); + context.dispatch("search"); + context.dispatch("searchdetail", ""); + } + } catch (e) { + context.commit("update_search_status", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async update(context, prm) { + context.commit("update_search_status_detail", 1) + try { + + let resp = await api.editVoucher(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_search_status_detail", 2) + context.commit("update_error_message", resp.message); + + let data = { + records: resp.data.records + } + + context.commit("update_alert_success", true); + context.commit("update_dialog_voucher", false); + var msg = `Sukses edit data dengan kode ${data.records[0].PaymentVoucherNumber}`; + context.commit("update_success_message", msg); + context.commit("update_selected_voucher", data.records[0]); + context.dispatch("search"); + context.dispatch("searchdetail", data.records[0].PaymentVoucherID); + } + } catch (e) { + context.commit("update_search_status_detail", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getPurchaseUpdateNew(context, prm) { + context.commit("update_load_status", 1) + try { + let resp = await api.getPurchaseUpdateNew(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_load_status", 3) + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_load_status", 2) + context.commit("update_error_message", ""); + let data = { + records: resp.data.records + } + + context.commit("update_purchaseList", data.records) + } + } catch (e) { + context.commit("update_load_status", 3) + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getVoucherDetailItem(context, param) { + try { + param.token = one_token() + let resp = await api.getVoucherDetailItem(param) + if (resp.status != 'OK') { + context.commit("update_error_message", resp.message) + context.commit("update_alert_error", true) + } else { + context.commit("update_list_voucher_detail", resp.data) + } + } catch (error) { + context.commit("update_error_message", error.message) + context.commit("update_alert_error", true) + } + }, + + async searchAccountItem(context, prm) { + try { + prm.token = one_token() + let resp = await api.searchAccBiaya(prm) + if (resp.status != "OK") { + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_error_message", ""); + context.commit("update_list_accitem", resp.data.records); + } + } catch (e) { + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async saveAccountItem(context, headerID) { + try { + let prm = { + token: one_token(), + PRDID: headerID, + detail: context.state.list_voucher_detail + } + + let resp = await api.saveAccountItem(prm) + if (resp.status != "OK") { + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_alert_success", true); + context.commit("update_success_message", "Success"); + + let ID = context.state.selected_voucher.PaymentVoucherID + context.dispatch("searchdetail", ID) + + context.commit("update_list_voucher_detail", []); + context.commit("update_dialog_account_item", false); + } + } catch (e) { + context.commit("update_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async moveTokasir(context) { + try { + let prm = { + token: one_token(), + ID: context.state.selected_voucher.PaymentVoucherID + } + let resp = await api.moveToKasir(prm) + if (resp.status != 'OK') { + context.commit("update_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + + let ID = context.state.selected_voucher.PaymentVoucherID + context.dispatch("searchdetail", ID) + + context.commit("update_alert_success", true); + context.commit("update_success_message", "Success"); + } + } catch (error) { + context.commit("update_error_message", error.message); + context.commit("update_alert_error", true); + } + } + } +}; + diff --git a/test/vuex/acc-one-payment-voucher/store.js b/test/vuex/acc-one-payment-voucher/store.js new file mode 100644 index 0000000..73530ca --- /dev/null +++ b/test/vuex/acc-one-payment-voucher/store.js @@ -0,0 +1,11 @@ +import voucher from "./modules/voucher.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + voucher: voucher, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-pendapatan-ar-v2/api/journal.js b/test/vuex/acc-one-pendapatan-ar-v2/api/journal.js new file mode 100644 index 0000000..13eef75 --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/api/journal.js @@ -0,0 +1,276 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function getPeriode(prm) { + try { + var resp = await axios.post(URL + "journalarv2/getPeriode", prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search( + token, + xdate, + periodeid, + current_page, + search, + branchCode, + regionalId +) { + try { + var resp = await axios.post(URL + "journalarv2/search", { + token: token, + xdate: xdate, + periodeid: periodeid, + current_page: current_page, + search: search, + branchCode: branchCode, + regionalId: regionalId + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function insertAr(branchCode, date, jurnalID) { + try { + var resp = await axios.get( + URL + `mediajurnalauto/insertAr/${branchCode}/${date}/1/${jurnalID}` + ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRegional(prm) { + try { + var resp = await axios.post(URL + "journalarv2/getRegional", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getBranch(prm) { + try { + var resp = await axios.post(URL + "journalarv2/getBranch", prm); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var resp = await axios.post(URL + "journalarv2/getUserApproveLevel", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListingCOA(params) { + try { + var resp = await axios.post(URL + "journalarv2/getListingCOA", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function requestEditJurnal(params) { + try { + const resp = await axios.post(URL + "JournalVerifEdit/requestEditJurnal", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + const data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditJurnal(params) { + try { + var resp = await axios.post(URL + "JournalVerifEdit/saveEditJurnal", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function changeJurnalToPosted(params) { + try { + var resp = await axios.post(URL + "journalarv2/changeJurnalToPosted", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getTotalJurnalNotPostedPerPeriod(params) { + try { + var resp = await axios.post(URL + "journalarv2/getTotalJurnalNotPostedPerPeriod", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function closeJurnalPerPeriode(params) { + try { + var resp = await axios.post(URL + "journalarv2/closeJurnalPerPeriode", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataJurnalNotClosedPerPeriod(params) { + try { + var resp = await axios.post(URL + "journalarv2/getDataJurnalNotClosedPerPeriod", params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} diff --git a/test/vuex/acc-one-pendapatan-ar-v2/components/dialogCloseJurnal.vue b/test/vuex/acc-one-pendapatan-ar-v2/components/dialogCloseJurnal.vue new file mode 100644 index 0000000..417ffbb --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/components/dialogCloseJurnal.vue @@ -0,0 +1,76 @@ + + + diff --git a/test/vuex/acc-one-pendapatan-ar-v2/components/dialogEditJurnal.vue b/test/vuex/acc-one-pendapatan-ar-v2/components/dialogEditJurnal.vue new file mode 100644 index 0000000..ba0095c --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/components/dialogEditJurnal.vue @@ -0,0 +1,223 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-pendapatan-ar-v2/components/dialogPostingJurnal.vue b/test/vuex/acc-one-pendapatan-ar-v2/components/dialogPostingJurnal.vue new file mode 100644 index 0000000..0ae425c --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/components/dialogPostingJurnal.vue @@ -0,0 +1,68 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-pendapatan-ar-v2/components/dialogRequestEditJurnal.vue b/test/vuex/acc-one-pendapatan-ar-v2/components/dialogRequestEditJurnal.vue new file mode 100644 index 0000000..92715a8 --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/components/dialogRequestEditJurnal.vue @@ -0,0 +1,58 @@ + + + diff --git a/test/vuex/acc-one-pendapatan-ar-v2/components/oneMediaJournalList.vue b/test/vuex/acc-one-pendapatan-ar-v2/components/oneMediaJournalList.vue new file mode 100644 index 0000000..a7da3bb --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/components/oneMediaJournalList.vue @@ -0,0 +1,1245 @@ + + + + + diff --git a/test/vuex/acc-one-pendapatan-ar-v2/index.php b/test/vuex/acc-one-pendapatan-ar-v2/index.php new file mode 100644 index 0000000..a736dd6 --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-pendapatan-ar-v2/modules/journal.js b/test/vuex/acc-one-pendapatan-ar-v2/modules/journal.js new file mode 100644 index 0000000..1834dfe --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/modules/journal.js @@ -0,0 +1,585 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/journal.js"; + +export default { + namespaced: true, + state: { + search_status: 0, + current_page: 1, + x_search: "", + search_error_message: "", + last_id: -1, + coas: [], + total_coas: 0, + selected_coa: {}, + dialog_form_coa: false, + act: "new", + save_status: 0, + save_error_message: "", + errors: [], + alert_success: false, + msg_success: "", + alert_error: false, + dialog_error: false, + open_print: false, + + // ---- + xdate: moment(new Date()).format("YYYY-MM-DD"), + end_date: moment(new Date()).format("YYYY-MM-DD"), + journals: [], + selected_journal: {}, + summary: {}, + dialog_form_detail: false, + periodeList: [], + selected_periode: {}, + loading: false, + dialog_form_periode: false, + autocomplete_status: 0, + search_status: 0, + total_journal: 0, + jurnaldetails: [], + dialog_error_jurnal: false, + msgerrjurnallist: [], + regionals: [], + selected_regional: {}, + branchs: [], + selected_branch: {}, + xsearch: "", + user: one_user(), + open_dialog_info: false, + msg_info: "", + + // -- + dialog_edit_journal: false, + user_level: {}, + list_coa: [], + journal_edit: [], + dialog_confirm_posting: false, + total_jurnal_not_posted: [], + dialog_request_edit: false, + + // --- + dialog_close_jurnal: false, + jurnal_to_close: [] + }, + mutations: { + update_search_status(state, val) { + state.search_status = val; + }, + update_current_page(state, val) { + state.current_page = val; + }, + update_x_search(state, val) { + state.x_search = val; + state.current_page = 1; + }, + update_search_error_message(state, val) { + state.search_error_message = val; + }, + update_last_id(state, val) { + state.last_id = val; + }, + update_coas(state, val) { + state.coas = val; + }, + update_total_coas(state, val) { + state.total_coas = val; + }, + update_selected_coa(state, val) { + state.selected_coa = val; + }, + update_dialog_form_coa(state, val) { + state.dialog_form_coa = val; + }, + update_act(state, val) { + state.act = val; + }, + update_save_status(state, val) { + state.save_status = val; + }, + update_save_error_message(state, val) { + state.save_error_message = val; + }, + update_errors(state, val) { + state.errors = val; + }, + update_alert_success(state, val) { + state.alert_success = val; + }, + update_msg_success(state, val) { + state.msg_success = val; + }, + update_alert_error(state, val) { + state.alert_error = val; + }, + update_dialog_error(state, val) { + state.dialog_error = val; + }, + update_open_print(state, value) { + state.open_print = value; + }, + + // --- + update_xdate(state, val) { + state.xdate = val; + }, + update_end_date(state, val) { + state.end_date = val; + }, + update_journals(state, val) { + state.journals = val; + }, + update_selected_journal(state, val) { + state.selected_journal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialog_form_detail(state, val) { + state.dialog_form_detail = val; + }, + update_periodeList(state, val) { + state.periodeList = val; + }, + update_selected_periode(state, val) { + state.selected_periode = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_dialog_form_periode(state, val) { + state.dialog_form_periode = val; + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val; + }, + update_search_status(state, val) { + state.search_status = val; + }, + update_total_journal(state, val) { + state.total_journal = val; + }, + update_jurnaldetails(state, val) { + state.jurnaldetails = val; + }, + update_dialog_error_jurnal(state, val) { + state.dialog_error_jurnal = val; + }, + update_msgerrjurnallist(state, val) { + state.msgerrjurnallist = val; + }, + update_regionals(state, val) { + state.regionals = val; + }, + update_selected_regional(state, val) { + state.selected_regional = val; + }, + update_branchs(state, val) { + state.branchs = val; + }, + update_selected_branch(state, val) { + state.selected_branch = val; + }, + update_xsearch(state, val) { + state.xsearch = val; + state.current_page = 1; + }, + update_user(state, val) { + state.user = val; + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val; + }, + update_msg_info(state, val) { + state.msg_info = val; + }, + + // + update_dialog_edit_journal(state, val) { + state.dialog_edit_journal = val; + }, + update_user_level(state, val) { + state.user_level = val; + }, + update_list_coa(state, val) { + state.list_coa = val; + }, + update_journal_edit(state, val) { + state.journal_edit = val; + }, + update_dialog_confirm_posting(state, val) { + state.dialog_confirm_posting = val; + }, + update_total_jurnal_not_posted(state, val) { + state.total_jurnal_not_posted = val; + }, + update_dialog_request_edit(state, val) { + state.dialog_request_edit = val; + }, + + update_dialog_close_jurnal(state, val) { + state.dialog_close_jurnal = val; + }, + update_jurnal_to_close(state, val) { + state.jurnal_to_close = val; + } + }, + actions: { + async getPeriode(context) { + context.commit("update_autocomplete_status", 1); + try { + let prm = {}; + prm.token = one_token(); + let resp = await api.getPeriode(prm); + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_autocomplete_status", 2); + let data = resp.data; + context.commit("update_periodeList", resp.data); + + // Ambil bulan dan tahun sekarang + let now = new Date(); + let currentMonth = now.getMonth() + 1; // getMonth() dimulai dari 0 (Jan = 0) + let currentYear = now.getFullYear().toString(); // Ambil tahun dalam bentuk string + + // Cari data dengan periodeMonth dan periodeYear yang cocok + let selectedPeriode = data.find( + (p) => + p.periodeMonth == currentMonth.toString() && + p.periodeYear == currentYear + ); + + // Jika tidak ditemukan, gunakan data pertama sebagai default + if (!selectedPeriode) { + selectedPeriode = data[0]; + } + + context.commit("update_selected_periode", selectedPeriode); + } + } catch (e) { + context.commit("update_autocomplete_status", 3); + } + }, + async search(context, prm) { + context.commit("update_search_status", 1); + try { + let resp = await api.search( + one_token(), + prm.xdate, + prm.periodeid, + prm.current_page, + prm.search, + prm.branchCode, + prm.regionalId + ); + if (resp.status != "OK") { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", resp.message); + } else { + context.commit("update_search_status", 2); + context.commit("update_search_error_message", ""); + let data = { + records: resp.data.records, + total: resp.data.total + }; + + context.commit("update_journals", data.records); + context.commit("update_total_journal", data.total); + } + } catch (e) { + context.commit("update_search_status", 3); + context.commit("update_search_error_message", e.message); + } + }, + + async insertAr(context, prm) { + context.commit("update_save_status", 1); + try { + let branchCode = prm.branchCode; + let date = prm.date; + let jurnalID = prm.jurnalID; + let resp = await api.insertAr(branchCode, date, jurnalID); + if (resp.status != "OK") { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", resp.message); + context.commit("update_alert_error", true); + } else { + context.commit("update_save_status", 2); + context.commit("update_save_error_message", resp.message); + let data = { + total: resp.data.total + }; + + context.commit("update_alert_success", true); + var msg = resp.data.msg; + context.commit("update_msg_success", msg); + context.dispatch("search", { + branchCode: prm.branchCode, + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + } + } catch (e) { + context.commit("update_save_status", 3); + context.commit("update_save_error_message", e.message); + context.commit("update_alert_error", true); + } + }, + + async getRegional(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getRegional({ + token: one_token(), + regionalId: context.state.user.S_RegionalID + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_regionals", data.records); + context.commit("update_selected_regional", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async getBranch(context) { + context.commit("update_autocomplete_status", 1); + try { + let resp = await api.getBranch({ + token: one_token(), + regionalId: context.state.selected_regional.S_RegionalID, + branchCode: context.state.user.M_BranchCode + }); + if (resp.status != "OK") { + context.commit("update_search_error_message", resp.message); + context.commit("update_autocomplete_status", 3); + } else { + context.commit("update_search_error_message", ""); + context.commit("update_autocomplete_status", 2); + let data = { + records: resp.data.records, + selected: resp.data.selected + }; + + context.commit("update_branchs", data.records); + context.commit("update_selected_branch", data.selected); + } + } catch (e) { + context.commit("update_search_error_message", e.message); + context.commit("update_autocomplete_status", 3); + } + }, + + async postingJurnal(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.changeJurnalToPosted(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_total_jurnal_not_posted", []); + context.commit("update_dialog_confirm_posting", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getUserApprovalLevel(context) { + try { + let param = { token: one_token() }; + const resp = await api.getUserApproveLevel(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getListingCOA(context) { + try { + let param = { + token: one_token(), + keyword: "" + }; + const resp = await api.getListingCOA(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_list_coa", resp.data); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async requestEditJurnal(context) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + staffID: context.state.user.M_UserID, + staffName: context.state.user.M_UserUsername + }; + const resp = await api.requestEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + context.commit("update_dialog_request_edit", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async saveEditJurnal(context, newdetail) { + try { + let param = { + token: one_token(), + jurnalID: context.state.selected_journal.jurnalID, + jurnalRequestEditID: context.state.selected_journal.JurnalRequestEditID, + oldjurnaltx: context.state.selected_journal.detailtx, + newjurnaltx: newdetail + }; + const resp = await api.saveEditJurnal(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_dialog_edit_journal", false); + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async totalJurnalNotPostedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getTotalJurnalNotPostedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_total_jurnal_not_posted", resp.data.total_jurnal ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async getDataJurnalNotClosedPerPeriod(context) { + try { + let param = { + token: one_token(), + periodeID: context.state.selected_periode.id + }; + const resp = await api.getDataJurnalNotClosedPerPeriod(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_jurnal_to_close", resp.data ?? []); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + }, + + async closeJurnalPerPeriode(context, typeid) { + try { + let param = { + token: one_token(), + jurnalTypeID: typeid, + periodeID: context.state.selected_periode.id + }; + const resp = await api.closeJurnalPerPeriode(param); + if (resp.status != "OK") { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", resp.message); + } else { + context.commit("update_msg_success", resp.data); + context.commit("update_alert_success", true); + + context.dispatch("search", { + branchCode: context.state.selected_branch.M_BranchCode ?? "", + regionalId: context.state.selected_regional.S_RegionalID, + search: context.state.x_search, + current_page: context.state.current_page, + xdate: context.state.xdate, + periodeid: context.state.selected_periode.id + }); + + context.commit("update_jurnal_to_close", []); + context.commit("update_dialog_close_jurnal", false); + } + } catch (error) { + context.commit("update_alert_error", true); + context.commit("update_save_error_message", error.message); + } + } + } +}; diff --git a/test/vuex/acc-one-pendapatan-ar-v2/store.js b/test/vuex/acc-one-pendapatan-ar-v2/store.js new file mode 100644 index 0000000..292d3b1 --- /dev/null +++ b/test/vuex/acc-one-pendapatan-ar-v2/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import journal from "./modules/journal.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + journal: journal, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-penyesuaian-harga/api/api.js b/test/vuex/acc-one-penyesuaian-harga/api/api.js new file mode 100644 index 0000000..96c02ad --- /dev/null +++ b/test/vuex/acc-one-penyesuaian-harga/api/api.js @@ -0,0 +1,101 @@ +const URL = "/one-api/mockup/purchase/cashier/PurchaseRequestDirectAdjusment/"; + +export async function search(params) { + try { + var resp = await axios.post(URL + "search", params) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function searchDetail(params) { + try { + var resp = await axios.post(URL + "searchDetail", params) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function updateAdjusment(params) { + try { + var resp = await axios.post(URL + "updateAdjustment", params) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function approveRealisasi(params) { + try { + var resp = await axios.post(URL + "approveRealisasi", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getListAccount(params) { + try { + var resp = await axios.post(URL + "getListAccount", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.statusText + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-penyesuaian-harga/components/adjustment_form.vue b/test/vuex/acc-one-penyesuaian-harga/components/adjustment_form.vue new file mode 100644 index 0000000..5923c2b --- /dev/null +++ b/test/vuex/acc-one-penyesuaian-harga/components/adjustment_form.vue @@ -0,0 +1,147 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-penyesuaian-harga/components/detail_voucher.vue b/test/vuex/acc-one-penyesuaian-harga/components/detail_voucher.vue new file mode 100644 index 0000000..efdb2c5 --- /dev/null +++ b/test/vuex/acc-one-penyesuaian-harga/components/detail_voucher.vue @@ -0,0 +1,178 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-penyesuaian-harga/components/listing_voucher.vue b/test/vuex/acc-one-penyesuaian-harga/components/listing_voucher.vue new file mode 100644 index 0000000..ccb89f9 --- /dev/null +++ b/test/vuex/acc-one-penyesuaian-harga/components/listing_voucher.vue @@ -0,0 +1,212 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-penyesuaian-harga/index.php b/test/vuex/acc-one-penyesuaian-harga/index.php new file mode 100644 index 0000000..8acdd91 --- /dev/null +++ b/test/vuex/acc-one-penyesuaian-harga/index.php @@ -0,0 +1,68 @@ + + + + + + + + + + One || Penyesuaian Harga + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-penyesuaian-harga/modules/voucher.js b/test/vuex/acc-one-penyesuaian-harga/modules/voucher.js new file mode 100644 index 0000000..d896e73 --- /dev/null +++ b/test/vuex/acc-one-penyesuaian-harga/modules/voucher.js @@ -0,0 +1,137 @@ +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + filter: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + search: '' + }, + listing_voucher: { + records: [], + total: 0 + }, + main_table_page: 1, + selected_voucher: {}, + list_detail_voucher: {}, + list_account: [], + detail_table_page: 1, + selected_detail_voucher: {}, + dialog_adjustment: false, + snackbar: { + isOpen: false, + color: 'info', + message: '' + }, + }, + mutations: { + update_filter(state, val) { + state.filter = val + }, + update_selected_voucher(state, val) { + state.selected_voucher = val + }, + update_listing_voucher(state, val) { + state.listing_voucher = val + }, + update_main_table_page(state, val) { + state.main_table_page = val + }, + update_list_detail_voucher(state, val) { + state.list_detail_voucher = val + }, + update_detail_table_page(state, val) { + state.detail_table_page = val + }, + update_selected_detail_voucher(state, val) { + state.selected_detail_voucher = val + }, + update_dialog_adjustment(state, val) { + state.dialog_adjustment = val + }, + update_snackbar(state, val) { + state.snackbar = val + }, + update_list_account(state, val) { + state.list_account = val + } + }, + actions: { + async search(context) { + var param = { + token: one_token(), + page: context.state.main_table_page, + ...context.state.filter + } + + let resp = await api.search(param) + if (resp.status != 'OK') { + let snk = {isOpen: true, color: 'error', message: '[Error] ' + resp.message} + context.commit("update_snackbar", snk) + } else { + context.commit("update_listing_voucher", resp.data) + } + }, + async searchDetail(context) { + var param = { + token: one_token(), + ID: context.state.selected_voucher.PaymentVoucherID + } + let resp = await api.searchDetail(param) + if (resp.status != 'OK') { + let snk = {isOpen: true, color: 'error', message: '[Error] ' + resp.message} + context.commit("update_snackbar", snk) + } else { + context.commit("update_list_detail_voucher", resp.data) + } + }, + async updateAdjusment(context) { + var param = { + token: one_token(), + prd_id: context.state.selected_detail_voucher.PurchaseRequestDirectID, + price_adj: context.state.selected_detail_voucher.PurchaseRequestDirectAdjustment, + account_adj: context.state.selected_detail_voucher.PurchaseRequestDirectAdjustmentAccount + } + + let resp = await api.updateAdjusment(param) + if (resp.status != 'OK') { + let snk = {isOpen: true, color: 'error', message: '[Error] ' + resp.message} + context.commit("update_snackbar", snk) + } else { + let snk = {isOpen: true, color: 'success', message: '[Succeed]'}; + context.commit("update_snackbar", snk) + context.dispatch("searchDetail"); + context.commit("update_selected_detail_voucher", {}); + context.commit("update_dialog_adjustment", false); + } + }, + async approveRealisasi(context) { + var param = { + token: one_token(), + ID: context.state.selected_voucher.PaymentVoucherID + } + + let resp = await api.approveRealisasi(param); + if (resp.status != 'OK') { + let snk = {isOpen: true, color: 'error', message: '[Error] ' + resp.message} + context.commit("update_snackbar", snk) + } else { + let snk = {isOpen: true, color: 'success', message: '[Succeed]'}; + context.commit("update_snackbar", snk) + context.dispatch("search"); + context.commit("update_selected_voucher", {}) + context.commit("update_list_detail_voucher", {}) + } + }, + async getListAccount(context) { + var resp = await api.getListAccount({token: one_token()}) + if (resp.status != 'OK') { + let snk = {isOpen: true, color: 'error', message: '[Error] ' + resp.message} + context.commit("update_snackbar", snk) + } else { + context.commit("update_list_account", resp.data) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-penyesuaian-harga/store.js b/test/vuex/acc-one-penyesuaian-harga/store.js new file mode 100644 index 0000000..73530ca --- /dev/null +++ b/test/vuex/acc-one-penyesuaian-harga/store.js @@ -0,0 +1,11 @@ +import voucher from "./modules/voucher.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + voucher: voucher, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-po-asset/api/api.js b/test/vuex/acc-one-po-asset/api/api.js new file mode 100644 index 0000000..ff825a9 --- /dev/null +++ b/test/vuex/acc-one-po-asset/api/api.js @@ -0,0 +1,81 @@ +const URL = "/one-api/mockup/purchase/order/PurchaseOrderAset/"; + +export async function getListSupplier(params) { + try { + var response = await axios.post(URL + "getListSupplier", params) + if (response.status !== 200) { + return { + status: 'ERR', + message: responsep.statusText + }; + } + + let data = response.data + return data + } catch (error) { + return { + status: 'ERR', + message: error.message + }; + } +} + +export async function getListCabang(params) { + try { + var response = await axios.post(URL + "getListCabang", params) + if (response.status !== 200) { + return { + status: 'ERR', + message: responsep.statusText + }; + } + + let data = response.data + return data + } catch (error) { + return { + status: 'ERR', + message: error.message + }; + } +} + +export async function searchRequestAset(params) { + try { + var response = await axios.post(URL + "searchRequestAset", params) + if (response.status !== 200) { + return { + status: 'ERR', + message: responsep.statusText + }; + } + + let data = response.data + return data + } catch (error) { + return { + status: 'ERR', + message: error.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + var response = await axios.post(URL + "getUserApproveLevel", params) + if (response.status !== 200) { + return { + status: 'ERR', + message: responsep.statusText + }; + } + + let data = response.data + return data + } catch (error) { + return { + status: 'ERR', + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-po-asset/components/dialog-add-attachment.vue b/test/vuex/acc-one-po-asset/components/dialog-add-attachment.vue new file mode 100644 index 0000000..8339348 --- /dev/null +++ b/test/vuex/acc-one-po-asset/components/dialog-add-attachment.vue @@ -0,0 +1,193 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-asset/components/dialog-add-item-aset.vue b/test/vuex/acc-one-po-asset/components/dialog-add-item-aset.vue new file mode 100644 index 0000000..5071ba8 --- /dev/null +++ b/test/vuex/acc-one-po-asset/components/dialog-add-item-aset.vue @@ -0,0 +1,244 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-asset/components/dialog-create-contract.vue b/test/vuex/acc-one-po-asset/components/dialog-create-contract.vue new file mode 100644 index 0000000..00eedcb --- /dev/null +++ b/test/vuex/acc-one-po-asset/components/dialog-create-contract.vue @@ -0,0 +1,259 @@ + + + diff --git a/test/vuex/acc-one-po-asset/components/dialog-delete-order.vue b/test/vuex/acc-one-po-asset/components/dialog-delete-order.vue new file mode 100644 index 0000000..ee87e44 --- /dev/null +++ b/test/vuex/acc-one-po-asset/components/dialog-delete-order.vue @@ -0,0 +1,61 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-asset/components/dialog-form-order-aset.vue b/test/vuex/acc-one-po-asset/components/dialog-form-order-aset.vue new file mode 100644 index 0000000..9470838 --- /dev/null +++ b/test/vuex/acc-one-po-asset/components/dialog-form-order-aset.vue @@ -0,0 +1,601 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-asset/components/main-layout.vue b/test/vuex/acc-one-po-asset/components/main-layout.vue new file mode 100644 index 0000000..7b7983a --- /dev/null +++ b/test/vuex/acc-one-po-asset/components/main-layout.vue @@ -0,0 +1,282 @@ + + + diff --git a/test/vuex/acc-one-po-asset/index.php b/test/vuex/acc-one-po-asset/index.php new file mode 100644 index 0000000..321387b --- /dev/null +++ b/test/vuex/acc-one-po-asset/index.php @@ -0,0 +1,60 @@ + + + + + + + + + + ONE + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-asset/modules/kontrak-asset.js b/test/vuex/acc-one-po-asset/modules/kontrak-asset.js new file mode 100644 index 0000000..488a767 --- /dev/null +++ b/test/vuex/acc-one-po-asset/modules/kontrak-asset.js @@ -0,0 +1,30 @@ +export default { + namespaced: true, + state: { + dialog_create_contract: false, + form_kontrak: { + nama_kontrak: '', + tanggal_kontrak: moment(new Date()).format('YYYY-MM-DD'), + supplierID_kontrak: '', + tanggalAwal_kontrak: moment(new Date()).format('YYYY-MM-DD'), + tanggalAkhir_kontrak: moment(new Date()).format('YYYY-MM-DD'), + durasi_cicilan: 1, + jumlah_cicilan: 1, + tanggalBayar_cicilan: 1, + besarNilai_cicilan: 0, + type_downpayment: 'nominal', + besarNilai_downpayment: 0, + type_pajak: 'persen', + besarNilai_pajak: 0 + } + }, + mutations: { + update_dialog_create_contract(state, val) { + state.dialog_create_contract = val + }, + update_form_kontrak(state, val) { + state.form_kontrak = val + } + }, + actions: {} +} diff --git a/test/vuex/acc-one-po-asset/modules/poasset.js b/test/vuex/acc-one-po-asset/modules/poasset.js new file mode 100644 index 0000000..60d3288 --- /dev/null +++ b/test/vuex/acc-one-po-asset/modules/poasset.js @@ -0,0 +1,179 @@ +import * as api from '../api/api.js'; + +export default { + namespaced: true, + state: { + /* common */ + snackbar: { + color: 'success', + msg: '', + state: false + }, + loading_process: false, + selected_orderaset: {}, + + /* main layout */ + filterpo: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + status: 'All', + search: '' + }, + list_status: ['All', 'Draft', 'Pending', 'Approved', 'Rejected', 'Completed'], + list_asetpo: { + records: [], + total: 0 + }, + currpage: 1, + + /* form order aset */ + dialog_form_orderaset: false, + list_supplier: [], + list_branch: [], + form_orderaset: { + podate: moment(new Date()).format('YYYY-MM-DD'), + supplierID: "", + reference: "", + branchcode: "", + typepajak: "percent", + valuepajak: 0, + typediskon: "percent", + valuediskon: 0 + }, + item_orderaset: [], + summary_orderaset: { + subtotal: 0, + diskon: 0, + pajak: 0, + total: 0 + }, + + dialog_add_itemaset: false, + list_requestaset: { + records: [], + total: 0 + }, + + /* delete order */ + dialog_deleteorder: false, + + /* attachment */ + dialog_attachment: false, + prview_attachment: [], + + }, + mutations: { + /* common */ + update_snackbar(state, val) { + state.snackbar = val + }, + update_loading_process(state, val) { + state.loading_process = val + }, + update_selected_orderaset(state, val) { + state.selected_orderaset = val + }, + + /* main layout */ + update_filterpo(state, val) { + state.filterpo = val + }, + update_list_status(state, val) { + state.list_status = val + }, + update_list_asetpo(state, val) { + state.list_asetpo = val + }, + update_currpage(state, val) { + state.currpage = val + }, + + /* form order aset */ + update_dialog_form_orderaset(state, val) { + state.dialog_form_orderaset = val + }, + update_list_supplier(state, val) { + state.list_supplier = val + }, + update_list_branch(state, val) { + state.list_branch = val + }, + update_form_orderaset(state, val) { + state.form_orderaset = val + }, + update_item_orderaset(state, val) { + state.item_orderaset = val + }, + update_summary_orderaset(state, val) { + state.summary_orderaset = val + }, + update_dialog_add_itemaset(state, val) { + state.dialog_add_itemaset = val + }, + update_list_requestaset(state, val) { + state.list_requestaset = val + }, + + /* delete order */ + update_dialog_deleteorder(state, val) { + state.dialog_deleteorder = val + }, + + /* attachment */ + update_dialog_attachment(state, val) { + state.dialog_attachment = val + }, + update_prview_attachment(state, val) { + state.prview_attachment = val + } + }, + actions: { + async lookupVendor(context) { + try { + const resp = await api.getListSupplier({token: one_token()}); + if (resp.status != 'OK') { + throw new Error(resp.message); + } else { + context.commit('update_list_supplier', resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + async lookupCabang(context) { + try { + const resp = await api.getListCabang({token: one_token()}); + if (resp.status != 'OK') { + throw new Error(resp.message); + } + + context.commit('update_list_branch', resp.data) + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + async lookupOrderRequest(context, keyword) { + try { + const form = context.state.form_orderaset + let param = { + token: one_token(), + branchcode: form.branchcode, + search: keyword, + currpage: 1, + supplierID: form.supplierID + } + const resp = await api.searchRequestAset(param) + if (resp.status != 'OK') { + throw new Error(resp.message); + } + + context.commit('update_list_requestaset', resp.data) + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + } + } +} diff --git a/test/vuex/acc-one-po-asset/store.js b/test/vuex/acc-one-po-asset/store.js new file mode 100644 index 0000000..ec641b2 --- /dev/null +++ b/test/vuex/acc-one-po-asset/store.js @@ -0,0 +1,13 @@ +import system from "../../../apps/modules/system/system.js"; +import kontrakAsset from "./modules/kontrak-asset.js"; +import poasset from "./modules/poasset.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + poasset: poasset, + kontrakAsset: kontrakAsset + }, + state: {}, + mutations: {}, + actions: {} +}); diff --git a/test/vuex/acc-one-po-jasa/api/api.js b/test/vuex/acc-one-po-jasa/api/api.js new file mode 100644 index 0000000..893e9ab --- /dev/null +++ b/test/vuex/acc-one-po-jasa/api/api.js @@ -0,0 +1,221 @@ +const URL = "/one-api/mockup/purchase/order/PurchaseOrderService/"; + +export async function getDaftarSupplier(params) { + try { + var response = await axios.post(URL + "getDaftarSupplier", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarCabang(params) { + try { + var response = await axios.post(URL + "getDaftarCabang", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarRequestJasa(params) { + try { + var response = await axios.post(URL + "searchRequestJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarPOJasa(params) { + try { + var response = await axios.post(URL + "getDaftarPOJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDataKontrakPOJasa(params) { + try { + var response = await axios.post(URL + "getDataKontrakPOJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function createPOjasa(params) { + try { + var response = await axios.post(URL + "createPOjasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function deletePOjasa(params) { + try { + var response = await axios.post(URL + "deletePOjasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function updateApprovalPO(params) { + try { + var response = await axios.post(URL + "updateApprovalPO", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function uploadAttachment(params) { + try { + var response = await axios.post(URL + "uploadAttachment", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function editPOjasa(params) { + try { + const response = await axios.post(URL + "editPOjasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + const data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarAttachment(params) { + try { + const response = await axios.post(URL + "getDaftarAttachment", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + const data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/components/dialogAddAttachment.vue b/test/vuex/acc-one-po-jasa/components/dialogAddAttachment.vue new file mode 100644 index 0000000..6511b5b --- /dev/null +++ b/test/vuex/acc-one-po-jasa/components/dialogAddAttachment.vue @@ -0,0 +1,209 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/components/dialogDeletePoJasa.vue b/test/vuex/acc-one-po-jasa/components/dialogDeletePoJasa.vue new file mode 100644 index 0000000..faeef11 --- /dev/null +++ b/test/vuex/acc-one-po-jasa/components/dialogDeletePoJasa.vue @@ -0,0 +1,75 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/components/dialogEditFormPoJasa.vue b/test/vuex/acc-one-po-jasa/components/dialogEditFormPoJasa.vue new file mode 100644 index 0000000..594d994 --- /dev/null +++ b/test/vuex/acc-one-po-jasa/components/dialogEditFormPoJasa.vue @@ -0,0 +1,748 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/components/dialogFormPoJasa.vue b/test/vuex/acc-one-po-jasa/components/dialogFormPoJasa.vue new file mode 100644 index 0000000..6ae1e16 --- /dev/null +++ b/test/vuex/acc-one-po-jasa/components/dialogFormPoJasa.vue @@ -0,0 +1,737 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/components/dialogSelectItemJasa.vue b/test/vuex/acc-one-po-jasa/components/dialogSelectItemJasa.vue new file mode 100644 index 0000000..30b6f08 --- /dev/null +++ b/test/vuex/acc-one-po-jasa/components/dialogSelectItemJasa.vue @@ -0,0 +1,224 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/components/dialogViewPoJasa.vue b/test/vuex/acc-one-po-jasa/components/dialogViewPoJasa.vue new file mode 100644 index 0000000..74f6e35 --- /dev/null +++ b/test/vuex/acc-one-po-jasa/components/dialogViewPoJasa.vue @@ -0,0 +1,384 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/components/layoutPoJasa.vue b/test/vuex/acc-one-po-jasa/components/layoutPoJasa.vue new file mode 100644 index 0000000..7ac73cc --- /dev/null +++ b/test/vuex/acc-one-po-jasa/components/layoutPoJasa.vue @@ -0,0 +1,325 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/index.php b/test/vuex/acc-one-po-jasa/index.php new file mode 100644 index 0000000..c72af25 --- /dev/null +++ b/test/vuex/acc-one-po-jasa/index.php @@ -0,0 +1,60 @@ + + + + + + + + + + One + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/test/vuex/acc-one-po-jasa/modules/poservice.js b/test/vuex/acc-one-po-jasa/modules/poservice.js new file mode 100644 index 0000000..bb08b48 --- /dev/null +++ b/test/vuex/acc-one-po-jasa/modules/poservice.js @@ -0,0 +1,405 @@ +import * as api from '../api/api.js'; + +export default { + namespaced: true, + state: { + /* utility */ + snackbar: { + color: 'success', + msg: '', + state: false + }, + + filterjasa: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + status: "All", + search: "" + }, + liststatus: ['All', 'Draft', 'Pending', 'Approved', 'Rejected', 'Completed'], + list_pojasa: { + records: [], + total: 0 + }, + currpage: 1, + + loading_process: false, + + /* dialog form po */ + dialog_formpo: false, + list_supplier: [], + list_branch: [], + type_kontrak: [ + { "name": "sekali beli", "value": "once" }, + { "name": "kontrak berjangka", "value": "period" }, + ], + form_pojasa: { + podate: moment(new Date()).format('YYYY-MM-DD'), + reference: "", + supplierID: "", + typepajak: "percent", + valuepajak: 0, + typediskon: "percent", + valuediskon: 0, + branchcode: 0, + typekontrak: 'once', + kontrakstart: moment(new Date()).format('YYYY-MM-DD'), + kontrakend: moment(new Date()).format('YYYY-MM-DD'), + PIOutQty: 1, + catatan: "" + }, + + /* dialog form edit po */ + dialog_editformpo: false, + + /* dialog request jasa */ + dialog_select_itemjasa: false, + list_requestjasa: { + records: [], + total: 0 + }, + selected_requestjasa: [], + summary_pojasa: { + subtotal: 0, + diskon: 0, + pajak: 0, + total: 0 + }, + + /* dialog delete jasa */ + dialog_deletepojasa: false, + deleted_pojasa: {}, + + /* dialog upload attachment */ + dialog_attachment: false, + pojasa_attachment: {}, + prview_attachment: [], + + /* dialog view po */ + dialog_viewpo: false + }, + mutations: { + update_snackbar(state, val) { + state.snackbar = val + }, + update_filterjasa(state, val) { + state.filterjasa = val + }, + update_liststatus(state, val) { + state.liststatus = val + }, + update_list_pojasa(state, val) { + state.list_pojasa = val + }, + update_currpage(state, val) { + state.currpage = val + }, + update_loading_process(state, val) { + state.loading_process = val + }, + + /* dialog form po */ + update_dialog_formpo(state, val) { + state.dialog_formpo = val + }, + update_list_supplier(state, val) { + state.list_supplier = val + }, + update_list_branch(state, val) { + state.list_branch = val + }, + update_type_kontrak(state, val) { + state.type_kontrak = val + }, + update_form_pojasa(state, val) { + state.form_pojasa = val + }, + + update_dialog_editformpo(state, val) { + state.dialog_editformpo = val + }, + + /* dialog select request jasa */ + update_dialog_select_itemjasa(state, val) { + state.dialog_select_itemjasa = val + }, + update_list_requestjasa(state, val) { + state.list_requestjasa = val + }, + update_selected_requestjasa(state, val) { + state.selected_requestjasa = val + }, + update_summary_pojasa(state, val) { + state.summary_pojasa = val + }, + + /* delete po jasa */ + update_dialog_deletepojasa(state, val) { + state.dialog_deletepojasa = val + }, + update_deleted_pojasa(state, val) { + state.deleted_pojasa = val + }, + + update_dialog_attachment(state, val) { + state.dialog_attachment = val + }, + update_pojasa_attachment(state, val) { + state.pojasa_attachment = val + }, + update_prview_attachment(state, val) { + state.prview_attachment = val + }, + + update_dialog_viewpo(state, val) { + state.dialog_viewpo = val + } + }, + actions: { + async lookupCabang(context) { + try { + const resp = await api.getDaftarCabang({token: one_token()}) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_list_branch", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupVendor(context) { + try { + const resp = await api.getDaftarSupplier({token: one_token()}) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_list_supplier", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupRequestJasa(context, keyword) { + try { + let pojasa = context.state.form_pojasa + let param = { + token: one_token(), + branchcode: pojasa.branchcode, + supplierID: pojasa.supplierID, + search: keyword + } + + const resp = await api.getDaftarRequestJasa(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_list_requestjasa", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupPOJasa(context) { + try { + let param = { + token: one_token(), + currpage: context.state.currpage, + ...context.state.filterjasa + } + + const resp = await api.getDaftarPOJasa(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit('update_list_pojasa', resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupDataPOJasa(context, poid) { + try { + let param = { + token: one_token(), + poID: poid + } + + const resp = await api.getDataKontrakPOJasa(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + let data = resp.data + + context.commit('update_form_pojasa', data) + context.commit('update_selected_requestjasa', data.detail) + context.commit('update_summary_pojasa', data.summary) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupAttachment(context, param) { + try { + param.token = one_token() + const resp = await api.getDaftarAttachment(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_prview_attachment", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async createPOJasa(context, param) { + try { + context.state.loading_process = true + param.token = one_token() + + const resp = await api.createPOjasa(param) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + context.state.loading_process = false + context.dispatch('lookupPOJasa') + context.commit('update_dialog_formpo', false) + } + + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async deletePOJasa(context) { + try { + context.state.loading_process = true + let param = { + token: one_token(), + poID: context.state.deleted_pojasa.PurchaseOrderID, + tjasaID: context.state.deleted_pojasa.T_KontrakJasaID + } + + const resp = await api.deletePOjasa(param) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + context.state.loading_process = false + context.dispatch('lookupPOJasa') + context.state.dialog_deletepojasa = false + } + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async sendRequestPO(context, poid) { + try { + context.state.loading_process = true + let param = { + token: one_token(), + approvelevel: "0", + poID: poid, + kontrakid: '0' + } + + const resp = await api.updateApprovalPO(param) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + + context.state.loading_process = false + context.dispatch('lookupPOJasa') + } + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async uploadAttachment(context, param) { + try { + context.state.loading_process = true + const resp = await api.uploadAttachment(param); + if (resp.status !== 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.state.loading_process = false + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + context.dispatch('lookupPOJasa') + context.state.dialog_attachment = false + } + } catch (error) { + context.state.loading_process = false; + let snac = {color: 'error', msg: error.message, state: true}; + context.commit('update_snackbar', snac); + } + }, + + async saveEditPOJasa(context, param) { + try { + context.state.loading_process = true + param.token = one_token() + + const resp = await api.editPOjasa(param) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.state.loading_process = false + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + context.dispatch('lookupPOJasa') + context.commit('update_dialog_editformpo', false) + } + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-po-jasa/store.js b/test/vuex/acc-one-po-jasa/store.js new file mode 100644 index 0000000..ec6d4dd --- /dev/null +++ b/test/vuex/acc-one-po-jasa/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js"; +import poservice from "./modules/poservice.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + poservice: poservice + }, + state: {}, + mutations: {}, + actions: {} +}); \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-biaya-cabang/api/api-presentase.js b/test/vuex/acc-one-presentase-biaya-cabang/api/api-presentase.js new file mode 100644 index 0000000..b66e894 --- /dev/null +++ b/test/vuex/acc-one-presentase-biaya-cabang/api/api-presentase.js @@ -0,0 +1,229 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function get_listing_type(params) { + try { + var resp = await axios.post(URL + 'presentasecost/listpresentasecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_list_detail_type(params) { + try { + var resp = await axios.post(URL + 'presentasecost/detailpresentasecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function insert_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasecost/inserttypepresentasecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function edit_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasecost/edittypepresentasecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function delete_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasecost/deletetypepresentasecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_list_regional(params) { + try { + var resp = await axios.post(URL + 'presentasecost/getlistregional', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_regional_branch(params) { + try { + var resp = await axios.post(URL + 'presentasecost/getregionalbranch', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function insert_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasecost/insertdetailprecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_current_value_detail(params) { + try { + var resp = await axios.post(URL + 'presentasecost/getvaluedetailprecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function edit_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasecost/editdetailprecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function delete_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasecost/deletedetailprecost', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function search_coa(params) { + try { + var resp = await axios.post(URL + 'presentasecost/searchcoa', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-biaya-cabang/components/listing-regional.vue b/test/vuex/acc-one-presentase-biaya-cabang/components/listing-regional.vue new file mode 100644 index 0000000..793f1b4 --- /dev/null +++ b/test/vuex/acc-one-presentase-biaya-cabang/components/listing-regional.vue @@ -0,0 +1,407 @@ + + + + + + diff --git a/test/vuex/acc-one-presentase-biaya-cabang/components/listing-tipe.vue b/test/vuex/acc-one-presentase-biaya-cabang/components/listing-tipe.vue new file mode 100644 index 0000000..68dbf5c --- /dev/null +++ b/test/vuex/acc-one-presentase-biaya-cabang/components/listing-tipe.vue @@ -0,0 +1,239 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-biaya-cabang/index.php b/test/vuex/acc-one-presentase-biaya-cabang/index.php new file mode 100644 index 0000000..e89303a --- /dev/null +++ b/test/vuex/acc-one-presentase-biaya-cabang/index.php @@ -0,0 +1,68 @@ + + + + + + + + + + Presentase Cabang + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-biaya-cabang/modules/presentase.js b/test/vuex/acc-one-presentase-biaya-cabang/modules/presentase.js new file mode 100644 index 0000000..e179a17 --- /dev/null +++ b/test/vuex/acc-one-presentase-biaya-cabang/modules/presentase.js @@ -0,0 +1,535 @@ +import * as api from '../api/api-presentase.js'; + +export default { + namespaced: true, + state: { + tabel_precab: {}, + pagination_precab: 1, + loading_precab: false, + selected_precab: {}, + input_precab: { + typeid: 0, + typename: '' + }, + tabel_detail: {}, + pagination_detail: 1, + loading_detail: false, + loading_api: false, + snackbar: { + isOpen: false, + color: "error", + msg: "" + }, + dialogFormType: false, + dialogFormDet: false, + list_regional: {}, + selected_input_reg: {}, + regional_branches: {}, + list_coa: {}, + selected_coa: {}, + }, + mutations: { + update_tabel_precab(state, data) { + state.tabel_precab = data + }, + update_pagination_precab(state, data) { + state.pagination_precab = data + }, + update_loading_precab(state, data) { + state.loading_precab = data + }, + update_selected_precab(state, data) { + state.selected_precab = data + }, + update_tabel_detail(state, data) { + state.tabel_detail = data + }, + update_pagination_detail(state, data) { + state.pagination_detail = data + }, + update_loading_detail(state, data) { + state.loading_detail = data + }, + update_input_precab(state, data) { + state.input_precab = data + }, + update_loading_api(state, data) { + state.loading_api = data + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_dialog_form(state, data) { + state.dialogFormType = data + }, + update_dialog_form_det(state, data) { + state.dialogFormDet = data + }, + update_list_regional(state, data) { + state.list_regional = data + }, + update_selected_input_reg(state, data) { + state.selected_input_reg = data + }, + update_regional_branches(state, data) { + state.regional_branches = data + }, + update_list_coa(state, data) { + state.list_coa = data + }, + update_selected_coa(state, data) { + state.selected_coa = data + }, + update_item_listcoa(state, data) { + state.regional_branches.records = data + } + }, + actions: { + async get_listing_type(context, params) { + context.commit("update_loading_precab", true) + try { + params.token = one_token() + let resp = await api.get_listing_type(params) + if (resp.status != "OK") { + context.commit("update_loading_precab", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_tabel_precab", resp.data) + context.commit("update_loading_precab", false) + } + } catch (error) { + context.commit("update_loading_precab", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_listing_reg(context, params) { + context.commit("update_loading_detail", true) + try { + params.token = one_token() + let resp = await api.get_list_detail_type(params) + if (resp.status != "OK") { + context.commit("update_loading_detail", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_tabel_detail", resp.data) + context.commit("update_loading_detail", false) + } + } catch (error) { + context.commit("update_loading_detail", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async insert_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.insert_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + }, + async edit_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.edit_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async delete_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.delete_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_regional_input(context) { + context.commit("update_loading_api", true) + try { + let resp = await api.get_list_regional({ token: one_token() }) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let ndata = resp.data.records + let exist = context.state.tabel_detail.records + let set_exist = new Set(exist.map(item => item.S_RegionalID)) + let res = ndata.filter(item => !set_exist.has(item.S_RegionalID)) + + let data = { + total: resp.data.total, + records: res + } + context.commit("update_loading_api", false) + context.commit("update_list_regional", data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_regional_branches(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.get_regional_branch(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + resp.data.records.forEach(item => { + item.listCoa = [] + }); + + context.commit("update_loading_api", false) + context.commit("update_regional_branches", resp.data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async insert_detail_precab(context) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + let input_reg = context.state.selected_input_reg + let input_branch = context.state.regional_branches.records + + let final_input = [] + input_branch.forEach( item => { + let a = { + branchcostpercentid: precab.BranchCostPercentID, + regionalid: input_reg.S_RegionalID, + branchid: item.M_BranchID, + value: item.branchValue, + noacc: item.accountNumber + } + final_input.push(a) + }); + + let params = { + branchvalue: final_input, + token: one_token() + } + + let resp = await api.insert_detail_precab(params) + if (resp.status != "OK") { + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecostid: precab.BranchCostPercentID, token: one_token()}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form_det", false) + } + }, + async edit_detail_precab(context) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + let input_branch = context.state.regional_branches.records + + let final_input = [] + input_branch.forEach( item => { + let a = { + precabdetailid: item.BranchCostPercentDetailID, + value: item.branchValue, + noacc: item.accountNumber + } + final_input.push(a) + }) + + let params = { + branchvalue: final_input, + token: one_token() + } + + let resp = await api.edit_detail_precab(params) + if (resp.status != "OK") { + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecostid: precab.BranchCostPercentID, token: one_token()}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form_det", false) + } + }, + async get_current_value_detail(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.get_current_value_detail(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + resp.data.records.forEach(item => { + item.branchValue = parseFloat(item.branchValue) + item.listCoa = [] + }); + + + context.commit("update_regional_branches", resp.data) + context.commit("update_loading_api", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_list_coa(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.search_coa(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let branc = context.state.regional_branches.records + if (branc) { + // let data = { + // data: resp.data.records, + // code: params.code + // } + + branc.forEach(item => { + if (item.M_BranchCode == params.code) { + item.listCoa = resp.data.records + } + }); + context.commit("update_item_listcoa", branc) + } + + context.commit("update_loading_api", false) + // context.commit("update_list_coa", resp.data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async delete_detail_precab(context, params) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + params.token = one_token() + let resp = await api.delete_detail_precab(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecostid: precab.BranchCostPercentID, token: one_token()}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-biaya-cabang/store.js b/test/vuex/acc-one-presentase-biaya-cabang/store.js new file mode 100644 index 0000000..4723b1d --- /dev/null +++ b/test/vuex/acc-one-presentase-biaya-cabang/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js"; +import presentase from "./modules/presentase.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + presentase: presentase + }, + state: {}, + mutations: {}, + actions: {} +}) \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-cabang/api/api-presentase.js b/test/vuex/acc-one-presentase-cabang/api/api-presentase.js new file mode 100644 index 0000000..542ce8b --- /dev/null +++ b/test/vuex/acc-one-presentase-cabang/api/api-presentase.js @@ -0,0 +1,229 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function get_listing_type(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/listpresentasecabang', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_list_detail_type(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/detailpresentasecabang', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function insert_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/inserttypepresentase', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function edit_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/edittypepresentase', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function delete_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/deletetypepresentase', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_list_regional(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/getlistregional', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_regional_branch(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/getregionalbranch', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function insert_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/insertdetailprecab', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_current_value_detail(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/getvaluedetailprecab', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function edit_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/editdetailprecab', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function delete_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/deletedetailprecab', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function search_coa(params) { + try { + var resp = await axios.post(URL + 'presentasecabang/searchcoa', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-cabang/components/listing-regional.vue b/test/vuex/acc-one-presentase-cabang/components/listing-regional.vue new file mode 100644 index 0000000..eb4e06c --- /dev/null +++ b/test/vuex/acc-one-presentase-cabang/components/listing-regional.vue @@ -0,0 +1,406 @@ + + + + + + diff --git a/test/vuex/acc-one-presentase-cabang/components/listing-tipe.vue b/test/vuex/acc-one-presentase-cabang/components/listing-tipe.vue new file mode 100644 index 0000000..17c4dab --- /dev/null +++ b/test/vuex/acc-one-presentase-cabang/components/listing-tipe.vue @@ -0,0 +1,237 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-cabang/index.php b/test/vuex/acc-one-presentase-cabang/index.php new file mode 100644 index 0000000..e89303a --- /dev/null +++ b/test/vuex/acc-one-presentase-cabang/index.php @@ -0,0 +1,68 @@ + + + + + + + + + + Presentase Cabang + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-cabang/modules/presentase.js b/test/vuex/acc-one-presentase-cabang/modules/presentase.js new file mode 100644 index 0000000..9000780 --- /dev/null +++ b/test/vuex/acc-one-presentase-cabang/modules/presentase.js @@ -0,0 +1,535 @@ +import * as api from '../api/api-presentase.js'; + +export default { + namespaced: true, + state: { + tabel_precab: {}, + pagination_precab: 1, + loading_precab: false, + selected_precab: {}, + input_precab: { + typeid: 0, + typename: '' + }, + tabel_detail: {}, + pagination_detail: 1, + loading_detail: false, + loading_api: false, + snackbar: { + isOpen: false, + color: "error", + msg: "" + }, + dialogFormType: false, + dialogFormDet: false, + list_regional: {}, + selected_input_reg: {}, + regional_branches: {}, + list_coa: {}, + selected_coa: {}, + }, + mutations: { + update_tabel_precab(state, data) { + state.tabel_precab = data + }, + update_pagination_precab(state, data) { + state.pagination_precab = data + }, + update_loading_precab(state, data) { + state.loading_precab = data + }, + update_selected_precab(state, data) { + state.selected_precab = data + }, + update_tabel_detail(state, data) { + state.tabel_detail = data + }, + update_pagination_detail(state, data) { + state.pagination_detail = data + }, + update_loading_detail(state, data) { + state.loading_detail = data + }, + update_input_precab(state, data) { + state.input_precab = data + }, + update_loading_api(state, data) { + state.loading_api = data + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_dialog_form(state, data) { + state.dialogFormType = data + }, + update_dialog_form_det(state, data) { + state.dialogFormDet = data + }, + update_list_regional(state, data) { + state.list_regional = data + }, + update_selected_input_reg(state, data) { + state.selected_input_reg = data + }, + update_regional_branches(state, data) { + state.regional_branches = data + }, + update_list_coa(state, data) { + state.list_coa = data + }, + update_selected_coa(state, data) { + state.selected_coa = data + }, + update_item_listcoa(state, data) { + state.regional_branches.records = data + } + }, + actions: { + async get_listing_type(context, params) { + context.commit("update_loading_precab", true) + try { + params.token = one_token() + let resp = await api.get_listing_type(params) + if (resp.status != "OK") { + context.commit("update_loading_precab", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_tabel_precab", resp.data) + context.commit("update_loading_precab", false) + } + } catch (error) { + context.commit("update_loading_precab", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_listing_reg(context, params) { + context.commit("update_loading_detail", true) + try { + params.token = one_token() + let resp = await api.get_list_detail_type(params) + if (resp.status != "OK") { + context.commit("update_loading_detail", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_tabel_detail", resp.data) + context.commit("update_loading_detail", false) + } + } catch (error) { + context.commit("update_loading_detail", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async insert_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.insert_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + }, + async edit_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.edit_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async delete_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.delete_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_regional_input(context) { + context.commit("update_loading_api", true) + try { + let resp = await api.get_list_regional({ token: one_token() }) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let ndata = resp.data.records + let exist = context.state.tabel_detail.records + let set_exist = new Set(exist.map(item => item.S_RegionalID)) + let res = ndata.filter(item => !set_exist.has(item.S_RegionalID)) + + let data = { + total: resp.data.total, + records: res + } + context.commit("update_loading_api", false) + context.commit("update_list_regional", data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_regional_branches(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.get_regional_branch(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + resp.data.records.forEach(item => { + item.listCoa = [] + }); + + context.commit("update_loading_api", false) + context.commit("update_regional_branches", resp.data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async insert_detail_precab(context) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + let input_reg = context.state.selected_input_reg + let input_branch = context.state.regional_branches.records + + let final_input = [] + input_branch.forEach( item => { + let a = { + branchpercentid: precab.BranchPercentID, + regionalid: input_reg.S_RegionalID, + branchid: item.M_BranchID, + value: item.branchValue, + noacc: item.accountNumber + } + final_input.push(a) + }); + + let params = { + branchvalue: final_input, + token: one_token() + } + + let resp = await api.insert_detail_precab(params) + if (resp.status != "OK") { + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecabangid: precab.BranchPercentID, token: one_token()}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form_det", false) + } + }, + async edit_detail_precab(context) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + let input_branch = context.state.regional_branches.records + + let final_input = [] + input_branch.forEach( item => { + let a = { + precabdetailid: item.BranchPercentDetailID, + value: item.branchValue, + noacc: item.accountNumber + } + final_input.push(a) + }) + + let params = { + branchvalue: final_input, + token: one_token() + } + + let resp = await api.edit_detail_precab(params) + if (resp.status != "OK") { + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecabangid: precab.BranchPercentID, token: one_token()}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form_det", false) + } + }, + async get_current_value_detail(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.get_current_value_detail(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + resp.data.records.forEach(item => { + item.branchValue = parseFloat(item.branchValue) + item.listCoa = [] + }); + + + context.commit("update_regional_branches", resp.data) + context.commit("update_loading_api", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_list_coa(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.search_coa(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let branc = context.state.regional_branches.records + if (branc) { + // let data = { + // data: resp.data.records, + // code: params.code + // } + + branc.forEach(item => { + if (item.M_BranchCode == params.code) { + item.listCoa = resp.data.records + } + }); + context.commit("update_item_listcoa", branc) + } + + context.commit("update_loading_api", false) + // context.commit("update_list_coa", resp.data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async delete_detail_precab(context, params) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + params.token = one_token() + let resp = await api.delete_detail_precab(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecabangid: precab.BranchPercentID, token: one_token()}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-cabang/store.js b/test/vuex/acc-one-presentase-cabang/store.js new file mode 100644 index 0000000..4723b1d --- /dev/null +++ b/test/vuex/acc-one-presentase-cabang/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js"; +import presentase from "./modules/presentase.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + presentase: presentase + }, + state: {}, + mutations: {}, + actions: {} +}) \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-fa-cabang/api/api-presentase.js b/test/vuex/acc-one-presentase-fa-cabang/api/api-presentase.js new file mode 100644 index 0000000..f6d2b21 --- /dev/null +++ b/test/vuex/acc-one-presentase-fa-cabang/api/api-presentase.js @@ -0,0 +1,229 @@ +const URL = "/one-api/mockup/masterdata/accounting/"; + +export async function get_listing_type(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/listpresentasecabang', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_list_detail_type(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/detailpresentasecabang', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function insert_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/inserttypepresentase', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function edit_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/edittypepresentase', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function delete_type_presentase(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/deletetypepresentase', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_list_regional(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/getlistregional', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_regional_branch(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/getregionalbranch', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function insert_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/insertdetailprecab', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function get_current_value_detail(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/getvaluedetailprecab', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function edit_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/editdetailprecab', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function delete_detail_precab(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/deletedetailprecab', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function search_coa(params) { + try { + var resp = await axios.post(URL + 'presentasefacabang/searchcoa', params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-fa-cabang/components/listing-regional.vue b/test/vuex/acc-one-presentase-fa-cabang/components/listing-regional.vue new file mode 100644 index 0000000..2bb0fd3 --- /dev/null +++ b/test/vuex/acc-one-presentase-fa-cabang/components/listing-regional.vue @@ -0,0 +1,406 @@ + + + + + + diff --git a/test/vuex/acc-one-presentase-fa-cabang/components/listing-tipe.vue b/test/vuex/acc-one-presentase-fa-cabang/components/listing-tipe.vue new file mode 100644 index 0000000..f6c159d --- /dev/null +++ b/test/vuex/acc-one-presentase-fa-cabang/components/listing-tipe.vue @@ -0,0 +1,237 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-fa-cabang/index.php b/test/vuex/acc-one-presentase-fa-cabang/index.php new file mode 100644 index 0000000..e89303a --- /dev/null +++ b/test/vuex/acc-one-presentase-fa-cabang/index.php @@ -0,0 +1,68 @@ + + + + + + + + + + Presentase Cabang + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-fa-cabang/modules/presentase.js b/test/vuex/acc-one-presentase-fa-cabang/modules/presentase.js new file mode 100644 index 0000000..eeed25b --- /dev/null +++ b/test/vuex/acc-one-presentase-fa-cabang/modules/presentase.js @@ -0,0 +1,535 @@ +import * as api from '../api/api-presentase.js'; + +export default { + namespaced: true, + state: { + tabel_precab: {}, + pagination_precab: 1, + loading_precab: false, + selected_precab: {}, + input_precab: { + typeid: 0, + typename: '' + }, + tabel_detail: {}, + pagination_detail: 1, + loading_detail: false, + loading_api: false, + snackbar: { + isOpen: false, + color: "error", + msg: "" + }, + dialogFormType: false, + dialogFormDet: false, + list_regional: {}, + selected_input_reg: {}, + regional_branches: {}, + list_coa: {}, + selected_coa: {}, + }, + mutations: { + update_tabel_precab(state, data) { + state.tabel_precab = data + }, + update_pagination_precab(state, data) { + state.pagination_precab = data + }, + update_loading_precab(state, data) { + state.loading_precab = data + }, + update_selected_precab(state, data) { + state.selected_precab = data + }, + update_tabel_detail(state, data) { + state.tabel_detail = data + }, + update_pagination_detail(state, data) { + state.pagination_detail = data + }, + update_loading_detail(state, data) { + state.loading_detail = data + }, + update_input_precab(state, data) { + state.input_precab = data + }, + update_loading_api(state, data) { + state.loading_api = data + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_dialog_form(state, data) { + state.dialogFormType = data + }, + update_dialog_form_det(state, data) { + state.dialogFormDet = data + }, + update_list_regional(state, data) { + state.list_regional = data + }, + update_selected_input_reg(state, data) { + state.selected_input_reg = data + }, + update_regional_branches(state, data) { + state.regional_branches = data + }, + update_list_coa(state, data) { + state.list_coa = data + }, + update_selected_coa(state, data) { + state.selected_coa = data + }, + update_item_listcoa(state, data) { + state.regional_branches.records = data + } + }, + actions: { + async get_listing_type(context, params) { + context.commit("update_loading_precab", true) + try { + params.token = one_token() + let resp = await api.get_listing_type(params) + if (resp.status != "OK") { + context.commit("update_loading_precab", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_tabel_precab", resp.data) + context.commit("update_loading_precab", false) + } + } catch (error) { + context.commit("update_loading_precab", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_listing_reg(context, params) { + context.commit("update_loading_detail", true) + try { + params.token = one_token() + let resp = await api.get_list_detail_type(params) + if (resp.status != "OK") { + context.commit("update_loading_detail", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_tabel_detail", resp.data) + context.commit("update_loading_detail", false) + } + } catch (error) { + context.commit("update_loading_detail", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async insert_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.insert_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + }, + async edit_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.edit_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async delete_type_presentase(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.delete_type_presentase(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + context.commit("update_loading_api", false) + context.dispatch("get_listing_type", {currpages: context.state.pagination_precab}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_regional_input(context) { + context.commit("update_loading_api", true) + try { + let resp = await api.get_list_regional({ token: one_token() }) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let ndata = resp.data.records + let exist = context.state.tabel_detail.records + let set_exist = new Set(exist.map(item => item.S_RegionalID)) + let res = ndata.filter(item => !set_exist.has(item.S_RegionalID)) + + let data = { + total: resp.data.total, + records: res + } + context.commit("update_loading_api", false) + context.commit("update_list_regional", data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_regional_branches(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.get_regional_branch(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + resp.data.records.forEach(item => { + item.listCoa = [] + }); + + context.commit("update_loading_api", false) + context.commit("update_regional_branches", resp.data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async insert_detail_precab(context) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + let input_reg = context.state.selected_input_reg + let input_branch = context.state.regional_branches.records + + let final_input = [] + input_branch.forEach( item => { + let a = { + branchpercentid: precab.BranchFaPercentID, + regionalid: input_reg.S_RegionalID, + branchid: item.M_BranchID, + value: item.branchValue, + noacc: item.accountNumber + } + final_input.push(a) + }); + + let params = { + branchvalue: final_input, + token: one_token() + } + + let resp = await api.insert_detail_precab(params) + if (resp.status != "OK") { + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecabangid: precab.BranchFaPercentID, token: one_token()}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form_det", false) + } + }, + async edit_detail_precab(context) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + let input_branch = context.state.regional_branches.records + + let final_input = [] + input_branch.forEach( item => { + let a = { + precabdetailid: item.BranchFaPercentDetailID, + value: item.branchValue, + noacc: item.accountNumber + } + final_input.push(a) + }) + + let params = { + branchvalue: final_input, + token: one_token() + } + + let resp = await api.edit_detail_precab(params) + if (resp.status != "OK") { + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecabangid: precab.BranchFaPercentID, token: one_token()}) + + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + context.commit("update_dialog_form_det", false) + } + }, + async get_current_value_detail(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.get_current_value_detail(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + resp.data.records.forEach(item => { + item.branchValue = parseFloat(item.branchValue) + item.listCoa = [] + }); + + + context.commit("update_regional_branches", resp.data) + context.commit("update_loading_api", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async get_list_coa(context, params) { + context.commit("update_loading_api", true) + try { + params.token = one_token() + let resp = await api.search_coa(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let branc = context.state.regional_branches.records + if (branc) { + // let data = { + // data: resp.data.records, + // code: params.code + // } + + branc.forEach(item => { + if (item.M_BranchCode == params.code) { + item.listCoa = resp.data.records + } + }); + context.commit("update_item_listcoa", branc) + } + + context.commit("update_loading_api", false) + // context.commit("update_list_coa", resp.data) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + async delete_detail_precab(context, params) { + context.commit("update_loading_api", true) + try { + let precab = context.state.selected_precab + params.token = one_token() + let resp = await api.delete_detail_precab(params) + if (resp.status != "OK") { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: resp.message + } + context.commit("update_snackbar", snac) + } else { + let page = context.state.pagination_detail + context.dispatch("get_listing_reg", {currpages: page, presentasecabangid: precab.BranchFaPercentID, token: one_token()}) + let snac = { + isOpen: true, + color: "success", + msg: "Sukses" + } + context.commit("update_snackbar", snac) + context.commit("update_loading_api", false) + context.commit("update_dialog_form_det", false) + } + } catch (error) { + context.commit("update_loading_api", false) + let snac = { + isOpen: true, + color: "error", + msg: error.message + } + context.commit("update_snackbar", snac) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-presentase-fa-cabang/store.js b/test/vuex/acc-one-presentase-fa-cabang/store.js new file mode 100644 index 0000000..4723b1d --- /dev/null +++ b/test/vuex/acc-one-presentase-fa-cabang/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js"; +import presentase from "./modules/presentase.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + presentase: presentase + }, + state: {}, + mutations: {}, + actions: {} +}) \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-inventaris/api/po.js b/test/vuex/acc-one-purchase-order-inventaris/api/po.js new file mode 100644 index 0000000..4b0a119 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/api/po.js @@ -0,0 +1,273 @@ +const URL = "/one-api/mockup/purchase/order/PurchaseOrderInventaris/"; +const URLRO = "/one-api/mockup/receive-item-po/receiveitempo/"; + +export async function getSupplier(payload) { + try { + var response = await axios.post(URL + "getSupplier", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItemCategory(payload) { + try { + var response = await axios.post(URL + "getItemCategory", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getWarehouse(payload) { + try { + var response = await axios.post(URL + "getWarehouse", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItem(payload) { + try { + var response = await axios.post(URL + "getItem", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItemUpdate(payload) { + try { + var response = await axios.post(URL + "getItemUpdate", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function saveOrder(payload) { + try { + var response = await axios.post(URL + "saveOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function search(payload) { + try { + var response = await axios.post(URL + "search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function requestOrder(payload) { + try { + var response = await axios.post(URL + "requestOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteOrder(payload) { + try { + var response = await axios.post(URL + "deleteOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateOrder(payload) { + try { + var response = await axios.post(URL + "updateOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approvePOrder(payload) { + try { + var response = await axios.post(URL + "approvePOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function isValidMultipleWarehouse(payload) { + try { + var response = await axios.post(URL + "isValidMultipleWarehouse", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getPoBySupplier(payload) { + try { + var response = await axios.post(URL + "getPoBySupplier", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function generateItemPO(params) { + try { + var response = await axios.post(URLRO + "generateItemPo", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-inventaris/components/dialogRiwayatPo.vue b/test/vuex/acc-one-purchase-order-inventaris/components/dialogRiwayatPo.vue new file mode 100644 index 0000000..9824cb0 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/components/dialogRiwayatPo.vue @@ -0,0 +1,308 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-inventaris/components/dialogView.vue b/test/vuex/acc-one-purchase-order-inventaris/components/dialogView.vue new file mode 100644 index 0000000..9c015e1 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/components/dialogView.vue @@ -0,0 +1,595 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-inventaris/components/po.vue b/test/vuex/acc-one-purchase-order-inventaris/components/po.vue new file mode 100644 index 0000000..0199881 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/components/po.vue @@ -0,0 +1,655 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-inventaris/components/poForm.vue b/test/vuex/acc-one-purchase-order-inventaris/components/poForm.vue new file mode 100644 index 0000000..5848c2f --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/components/poForm.vue @@ -0,0 +1,1813 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-inventaris/components/poForm_bckp.vue b/test/vuex/acc-one-purchase-order-inventaris/components/poForm_bckp.vue new file mode 100644 index 0000000..0d2f234 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/components/poForm_bckp.vue @@ -0,0 +1,1761 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-inventaris/functions/functions-pra-multiple-gudang-boleh-null.js b/test/vuex/acc-one-purchase-order-inventaris/functions/functions-pra-multiple-gudang-boleh-null.js new file mode 100644 index 0000000..de62aa7 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/functions/functions-pra-multiple-gudang-boleh-null.js @@ -0,0 +1,396 @@ +/** + * Utility functions for the ACC One Purchase Order application + */ + +// /** +// * Groups an array of objects by a specified key +// * @param {Array} array - The array of objects to group +// * @param {String} key - The key to group by +// * @returns {Object} - An object with keys representing the grouped values and arrays as values +// */ +// export const groupBy = (array, key) => { +// return array.reduce((result, item) => { +// const groupKey = item[key]; +// if (!result[groupKey]) { +// result[groupKey] = []; +// } +// result[groupKey].push(item); +// return result; +// }, {}); +// }; +/** + * Groups an array of objects by one or multiple keys + * @param {Array} array - The array of objects to group + * @param {Function|String|Array} key - The key(s) to group by. Can be a string, array of strings, or a function. + * @returns {Object} - An object with keys representing the grouped values and arrays as values + */ +export const groupBy = (array, key) => { + return array.reduce((result, item) => { + let groupKey; + + // Handle single key (string), multiple keys (array), or custom function + if (typeof key === 'function') { + groupKey = key(item); + } else if (Array.isArray(key)) { + groupKey = key.map(k => item[k]).join('_'); // Combine multiple keys with underscore + } else { + groupKey = item[key]; + } + + if (!result[groupKey]) { + result[groupKey] = []; + } + result[groupKey].push(item); + return result; + }, {}); +}; + +/** + * Groups purchase request data by M_ItemID + * @param {Array} purchaseRequestData - Array of purchase request objects + * @returns {Array} - Array of objects with M_ItemID, M_ItemCode, M_ItemDesc, unit information, converted PoQty, and Details array + */ +export const groupPurchaseRequestsByItemId = (purchaseRequestData) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'ItemUnitID']); + console.log("grouped"); + console.log(grouped); + + return Object.keys(grouped).map(itemId => { + const items = grouped[itemId]; + const firstItem = items[0]; + + // Calculate total PoQty from all items + const totalPoQty = calculateTotalQuantity(items, 'PoQty'); + + // Get the conversion factor from the first item + const conversionFactor = Number(firstItem.DefaultPurchase.UnitConvertAmount) || 1; + + // Convert the total quantity and round up if it's a decimal + const convertedPoQty = Math.ceil(convertUnits(totalPoQty, conversionFactor)); + + let price = 0; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - (Number(firstItem.discount) * (Number(firstItem.DefaultPurchase.SupplierPricePrice) / 100)); + } + if (firstItem.discountType === 'R') { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - Number(firstItem.discount); + } + + } else { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + } + + // Get the price from the first item + const realPrice = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + + // Calculate the total (PoQty * price) + const total = convertedPoQty * price; + + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + + + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + ItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + ItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + PoQty: convertedPoQty, + Price: price, + RealPrice: realPrice, + PriceAfterDiscount: price, + Total: total, + Details: items + }; + }); +}; + +/** + * Formats a number as currency (IDR) + * @param {Number} amount - The amount to format + * @returns {String} - Formatted currency string + */ +export const formatCurrency = (amount) => { + return new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }).format(amount); +}; + +/** + * Formats a date to a localized string + * @param {Date|String} date - The date to format + * @param {Object} options - Intl.DateTimeFormat options + * @returns {String} - Formatted date string + */ +export const formatDate = (date, options = { + year: 'numeric', + month: 'long', + day: 'numeric' +}) => { + if (!date) return ''; + const dateObj = typeof date === 'string' ? new Date(date) : date; + return new Intl.DateTimeFormat('id-ID', options).format(dateObj); +}; + +/** + * Calculates the total value of purchase requests + * @param {Array} items - Array of purchase request items + * @returns {Number} - Total value + */ +export const calculateTotal = (items) => { + return items.reduce((sum, item) => sum + (Number(item.Total) || 0), 0); +}; + +/** + * Calculates the total quantity of items + * @param {Array} items - Array of purchase request items + * @param {String} qtyField - The field name containing quantity (e.g., 'RequestQty', 'FlagQty', 'PoQty') + * @returns {Number} - Total quantity + */ +export const calculateTotalQuantity = (items, qtyField = 'RequestQty') => { + return items.reduce((sum, item) => sum + (Number(item[qtyField]) || 0), 0); +}; + +/** + * Converts units based on the conversion factor + * @param {Number} quantity - The quantity to convert + * @param {Number} conversionFactor - The conversion factor + * @returns {Number} - Converted quantity + */ +export const convertUnits = (quantity, conversionFactor) => { + return quantity / conversionFactor; +}; + +/** + * Filters purchase requests by branch + * @param {Array} items - Array of purchase request items + * @param {String|Array} branchCodes - Branch code(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByBranch = (items, branchCodes) => { + if (!branchCodes) return items; + + const codes = Array.isArray(branchCodes) ? branchCodes : [branchCodes]; + return items.filter(item => codes.includes(item.BranchCode)); +}; + +/** + * Filters purchase requests by regional + * @param {Array} items - Array of purchase request items + * @param {String|Array} regionalIds - Regional ID(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByRegional = (items, regionalIds) => { + if (!regionalIds) return items; + + const ids = Array.isArray(regionalIds) ? regionalIds : [regionalIds]; + return items.filter(item => ids.includes(item.S_RegionalID)); +}; + +/** + * Validates if a purchase request item has all required fields + * @param {Object} item - Purchase request item + * @returns {Boolean} - True if valid, false otherwise + */ +export const validatePurchaseRequestItem = (item) => { + const requiredFields = [ + 'M_ItemID', + 'M_ItemCode', + 'M_ItemDesc', + 'Price', + 'RequestQty' + ]; + + return requiredFields.every(field => item[field] !== undefined && item[field] !== null); +}; + +/** + * Sorts purchase request items by a specified field + * @param {Array} items - Array of purchase request items + * @param {String} field - Field to sort by + * @param {Boolean} ascending - Sort direction (true for ascending, false for descending) + * @returns {Array} - Sorted items + */ +export const sortPurchaseRequests = (items, field = 'M_ItemDesc', ascending = true) => { + return [...items].sort((a, b) => { + const valueA = a[field]; + const valueB = b[field]; + + if (typeof valueA === 'string' && typeof valueB === 'string') { + return ascending + ? valueA.localeCompare(valueB) + : valueB.localeCompare(valueA); + } + + return ascending + ? (valueA - valueB) + : (valueB - valueA); + }); +}; + +/** + * Validates purchase order data before saving + * @param {Object} context - Vuex context object + * @returns {Boolean} - Returns true if validation passes, false otherwise + */ +export const validatePurchaseOrder = (context) => { + if (context.state.loading) { + let snackbar = { + state: true, + type: "warning", + message: 'Loading sedang berlangsung harap menunggu ...', + }; + context.commit("update_snackbar", snackbar); + return false; + } + + let warningMsg = []; + if (context.state.selectedItem.length == 0) { + warningMsg.push('Belum memilih item'); + } + if (!context.state.selectedWarehouse || !context.state.selectedWarehouse.WarehouseID) { + warningMsg.push('Gudang belum dipilih'); + } + if (!context.state.selectedSupplier || !context.state.selectedSupplier.SupplierID) { + warningMsg.push('Supplier belum dipilih'); + } + if (context.state.discountType === 'Percentage') { + const discountValue = (context.state.itemTotal.total * context.state.discountAmount) / 100; + if (discountValue > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } else if (context.state.discountType === 'Absolute') { + if (context.state.discountAmount > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } + + context.state.summary.forEach(element => { + if (Number(element.discount) < 0) { + warningMsg.push('Diskon ' + element.M_ItemDesc + ' tidak boleh kurang dari 0'); + } + if (element.discountType === 'P') { + if (Number(element.discount) > 100) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi 100'); + } + } + if (element.discountType === 'R') { + if (Number(element.discount) > Number(element.RealPrice)) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi dari harga'); + } + } + }); + + if (warningMsg.length > 0) { + let snackbar = { + state: true, + type: "warning", + message: warningMsg.join(", "), + }; + context.commit("update_snackbar", snackbar); + return false; + } + + return true; +}; + +/** + * Menghitung total summary untuk purchase order + * @param {Array} summary - Array data summary + * @param {Number} taxPpn - Persentase pajak PPN + * @param {Number} taxPph - Persentase pajak PPH + * @param {String} discountType - Tipe diskon ('Percentage' atau 'Absolute') + * @param {Number} discountAmount - Jumlah diskon + * @returns {Object} - Object summaryTotal + */ +export const calculateSummaryTotal = (summary, taxPpn = 0, taxPph = 0, discountType = 'Percentage', discountAmount = 0) => { + if (!summary || summary.length === 0) { + return { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }; + } + + // Hitung total dari item summary + const total = summary.reduce((acc, item) => acc + (Number(item.Total) || 0), 0); + + // Hitung diskon berdasarkan tipe + let discount = discountAmount; + if (discountType === 'Percentage') { + discount = (discountAmount / 100) * total; + } + + // Hitung pajak + const newTotal = total - discount; + const ppn = (taxPpn / 100) * newTotal; + const pph = (taxPph / 100) * newTotal; + const tax = ppn + pph; + const finalTotal = newTotal + tax; + + // Return object summaryTotal + return { + total: total, + tax: tax, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: finalTotal, + }; +}; + + +/** + * Menghapus item dari summary dan selectedItem berdasarkan itemId atau detailId + * @param {Array} summary - Array data summary + * @param {Array} selectedItem - Array data selectedItem + * @param {String} itemId - ID item yang akan dihapus (opsional) + * @param {String} detailId - ID detail yang akan dihapus (opsional) + * @returns {Object} - Object berisi summary dan selectedItem yang sudah diupdate + */ +export const deleteItemFromSummary = (summary, selectedItem, itemId = null, detailId = null) => { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = summary.filter(item => item.M_ItemID !== itemId); + const newSelectedItem = selectedItem.filter(item => item.M_ItemID !== itemId); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = selectedItem.filter(item => item.PurchaseRequestFlagID !== detailId); + + // Regenerate summary dari selectedItem yang baru + const newSummary = groupPurchaseRequestsByItemId(newSelectedItem); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + return { + summary, + selectedItem + }; +}; \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-inventaris/functions/functions.js b/test/vuex/acc-one-purchase-order-inventaris/functions/functions.js new file mode 100644 index 0000000..442d8d8 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/functions/functions.js @@ -0,0 +1,412 @@ +/** + * Utility functions for the ACC One Purchase Order application + */ + +// /** +// * Groups an array of objects by a specified key +// * @param {Array} array - The array of objects to group +// * @param {String} key - The key to group by +// * @returns {Object} - An object with keys representing the grouped values and arrays as values +// */ +// export const groupBy = (array, key) => { +// return array.reduce((result, item) => { +// const groupKey = item[key]; +// if (!result[groupKey]) { +// result[groupKey] = []; +// } +// result[groupKey].push(item); +// return result; +// }, {}); +// }; +/** + * Groups an array of objects by one or multiple keys + * @param {Array} array - The array of objects to group + * @param {Function|String|Array} key - The key(s) to group by. Can be a string, array of strings, or a function. + * @returns {Object} - An object with keys representing the grouped values and arrays as values + */ +export const groupBy = (array, key) => { + return array.reduce((result, item) => { + let groupKey; + + // Handle single key (string), multiple keys (array), or custom function + if (typeof key === 'function') { + groupKey = key(item); + } else if (Array.isArray(key)) { + groupKey = key.map(k => item[k]).join('_'); // Combine multiple keys with underscore + } else { + groupKey = item[key]; + } + + if (!result[groupKey]) { + result[groupKey] = []; + } + result[groupKey].push(item); + return result; + }, {}); +}; + +/** + * Groups purchase request data by M_ItemID + * Terjadi jika ada beberapa item yang sama, maka akan digabungkan berdasarkan M_ItemID dan PoItemUnitID + * @param {Array} purchaseRequestData - Array of purchase request objects + * @returns {Array} - Array of objects with M_ItemID, M_ItemCode, M_ItemDesc, unit information, converted PoQty, and Details array + */ +export const groupPurchaseRequestsByItemId = (purchaseRequestData) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']); + // console.log("grouped"); + console.log(grouped); + + return Object.keys(grouped).map(itemId => { + const items = grouped[itemId]; + const firstItem = items[0]; + // console.log("firstItem for itemId", itemId, " : ", firstItem); + + /* Sebelum Kalkulasi Konversi Item di BE */ + // // Calculate total PoQty from all items + // const totalPoQty = calculateTotalQuantity(items, 'PoQty'); + // // Get the conversion factor from the first item + // const conversionFactor = Number(firstItem.DefaultPurchase.UnitConvertAmount) || 1; + // // Convert the total quantity and round up if it's a decimal + // const convertedPoQty = Math.ceil(convertUnits(totalPoQty, conversionFactor)); + + /* Sesudah Kalkulasi Konversi Item di BE getItem() */ + const totalPoQty = calculateTotalQuantity(items, 'PoQty') + // console.log("Total PoQty for itemId", itemId, " : ", totalPoQty); + + // get price real or default supplier price + const realPrice = Number(firstItem.RealPrice ?? firstItem.DefaultPurchase.SupplierPricePrice) || 0; + + // let price = 0; + + // calculagte price after discount + let priceAfterDiscount = realPrice; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + priceAfterDiscount = realPrice - (Number(firstItem.discount) * (realPrice / 100)); + } + if (firstItem.discountType === 'R') { + priceAfterDiscount = realPrice - Number(firstItem.discount); + } + + } else { + priceAfterDiscount = realPrice || 0; + } + + // Get the price from the first item + // const realPrice = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + + // Calculate the total (PoQty * priceAfterDiscount) + const total = totalPoQty * priceAfterDiscount; + + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + TotalPoQty: totalPoQty, + Price: priceAfterDiscount, + RealPrice: realPrice, + PriceAfterDiscount: priceAfterDiscount, + Total: total, + Details: items + }; + }); +}; + +/** + * Formats a number as currency (IDR) + * @param {Number} amount - The amount to format + * @returns {String} - Formatted currency string + */ +export const formatCurrency = (amount) => { + return new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }).format(amount); +}; + +/** + * Formats a date to a localized string + * @param {Date|String} date - The date to format + * @param {Object} options - Intl.DateTimeFormat options + * @returns {String} - Formatted date string + */ +export const formatDate = (date, options = { + year: 'numeric', + month: 'long', + day: 'numeric' +}) => { + if (!date) return ''; + const dateObj = typeof date === 'string' ? new Date(date) : date; + return new Intl.DateTimeFormat('id-ID', options).format(dateObj); +}; + +/** + * Calculates the total value of purchase requests + * @param {Array} items - Array of purchase request items + * @returns {Number} - Total value + */ +export const calculateTotal = (items) => { + return items.reduce((sum, item) => sum + (Number(item.Total) || 0), 0); +}; + +/** + * Calculates the total quantity of items + * @param {Array} items - Array of purchase request items + * @param {String} qtyField - The field name containing quantity (e.g., 'PoQty') + * @returns {Number} - Total quantity + */ +export const calculateTotalQuantity = (items, qtyField = 'PoQty') => { + // console.log("Items in calculateTotalQuantity:", items); + return items.reduce((sum, item) => sum + (Number(item[qtyField]) || 0), 0); +}; + +/** + * Converts units based on the conversion factor + * @param {Number} quantity - The quantity to convert + * @param {Number} conversionFactor - The conversion factor + * @returns {Number} - Converted quantity + */ +export const convertUnits = (quantity, conversionFactor) => { + return quantity / conversionFactor; +}; + +/** + * Filters purchase requests by branch + * @param {Array} items - Array of purchase request items + * @param {String|Array} branchCodes - Branch code(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByBranch = (items, branchCodes) => { + if (!branchCodes) return items; + + const codes = Array.isArray(branchCodes) ? branchCodes : [branchCodes]; + return items.filter(item => codes.includes(item.BranchCode)); +}; + +/** + * Filters purchase requests by regional + * @param {Array} items - Array of purchase request items + * @param {String|Array} regionalIds - Regional ID(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByRegional = (items, regionalIds) => { + if (!regionalIds) return items; + + const ids = Array.isArray(regionalIds) ? regionalIds : [regionalIds]; + return items.filter(item => ids.includes(item.S_RegionalID)); +}; + +/** + * Validates if a purchase request item has all required fields + * @param {Object} item - Purchase request item + * @returns {Boolean} - True if valid, false otherwise + */ +export const validatePurchaseRequestItem = (item) => { + const requiredFields = [ + 'M_ItemID', + 'M_ItemCode', + 'M_ItemDesc', + 'Price', + 'RequestQty' + ]; + + return requiredFields.every(field => item[field] !== undefined && item[field] !== null); +}; + +/** + * Sorts purchase request items by a specified field + * @param {Array} items - Array of purchase request items + * @param {String} field - Field to sort by + * @param {Boolean} ascending - Sort direction (true for ascending, false for descending) + * @returns {Array} - Sorted items + */ +export const sortPurchaseRequests = (items, field = 'M_ItemDesc', ascending = true) => { + return [...items].sort((a, b) => { + const valueA = a[field]; + const valueB = b[field]; + + if (typeof valueA === 'string' && typeof valueB === 'string') { + return ascending + ? valueA.localeCompare(valueB) + : valueB.localeCompare(valueA); + } + + return ascending + ? (valueA - valueB) + : (valueB - valueA); + }); +}; + +/** + * Validates purchase order data before saving + * @param {Object} context - Vuex context object + * @returns {Boolean} - Returns true if validation passes, false otherwise + */ +export const validatePurchaseOrder = (context) => { + if (context.state.loading) { + let snackbar = { + state: true, + type: "warning", + message: 'Loading sedang berlangsung harap menunggu ...', + }; + context.commit("update_snackbar", snackbar); + return false; + } + + let warningMsg = []; + if (context.state.selectedItem.length == 0) { + warningMsg.push('Belum memilih item'); + } + if (!context.state.refNumber || context.state.refNumber.trim() === '') { + warningMsg.push('Nomor Referensi belum diisi'); + } + if (!context.state.selectedWarehouse || !context.state.selectedWarehouse.WarehouseID && context.state.warehouseType !== 'Multiple') { + warningMsg.push('Tipe Gudang Single Harus memilih Gudang'); + } + if (!context.state.selectedSupplier || !context.state.selectedSupplier.SupplierID) { + warningMsg.push('Supplier belum dipilih'); + } + if (context.state.discountType === 'Percentage') { + const discountValue = (context.state.itemTotal.total * context.state.discountAmount) / 100; + if (discountValue > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } else if (context.state.discountType === 'Absolute') { + if (context.state.discountAmount > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } + + context.state.summary.forEach(element => { + if (Number(element.discount) < 0) { + warningMsg.push('Diskon ' + element.M_ItemDesc + ' tidak boleh kurang dari 0'); + } + if (element.discountType === 'P') { + if (Number(element.discount) > 100) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi 100'); + } + } + if (element.discountType === 'R') { + if (Number(element.discount) > Number(element.RealPrice)) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi dari harga'); + } + } + }); + + if (warningMsg.length > 0) { + let snackbar = { + state: true, + type: "warning", + message: warningMsg.join(", "), + }; + context.commit("update_snackbar", snackbar); + return false; + } + + return true; +}; + +/** + * Menghitung total summary untuk purchase order + * @param {Array} summary - Array data summary + * @param {Number} taxPpn - Persentase pajak PPN + * @param {Number} taxPph - Persentase pajak PPH + * @param {String} discountType - Tipe diskon ('Percentage' atau 'Absolute') + * @param {Number} discountAmount - Jumlah diskon + * @returns {Object} - Object summaryTotal + */ +export const calculateSummaryTotal = (summary, typePpnSelected = 'Percentage', taxPpn = 0, taxPph = 0, discountType = 'Percentage', discountAmount = 0) => { + if (!summary || summary.length === 0) { + return { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }; + } + + // Hitung total dari item summary + const total = summary.reduce((acc, item) => acc + (Number(item.Total) || 0), 0); + + // Hitung diskon berdasarkan tipe + let discount = discountAmount; + if (discountType === 'Percentage') { + discount = (discountAmount / 100) * total; + } + + // Hitung pajak + const newTotal = total - discount; + let ppn = taxPpn; + if (typePpnSelected === 'Percentage' && taxPpn > 0) { + ppn = (taxPpn / 100) * newTotal; + } + const pph = (taxPph / 100) * newTotal; + const tax = ppn + pph; + const finalTotal = newTotal + tax; + + // Return object summaryTotal + return { + total: total, + tax: tax, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: finalTotal, + }; +}; + + +/** + * Menghapus item dari summary dan selectedItem berdasarkan itemId atau detailId + * @param {Array} summary - Array data summary + * @param {Array} selectedItem - Array data selectedItem + * @param {String} itemId - ID item yang akan dihapus (opsional) + * @param {String} detailId - ID detail yang akan dihapus (opsional) + * @returns {Object} - Object berisi summary dan selectedItem yang sudah diupdate + */ +export const deleteItemFromSummary = (summary, selectedItem, itemId = null, detailId = null) => { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = summary.filter(item => item.M_ItemID !== itemId); + const newSelectedItem = selectedItem.filter(item => item.M_ItemID !== itemId); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = selectedItem.filter(item => item.PurchaseRequestFlagID !== detailId); + + // Regenerate summary dari selectedItem yang baru + const newSummary = groupPurchaseRequestsByItemId(newSelectedItem); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + return { + summary, + selectedItem + }; +}; \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-inventaris/index.php b/test/vuex/acc-one-purchase-order-inventaris/index.php new file mode 100644 index 0000000..d3024d3 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-inventaris/modules/po.js b/test/vuex/acc-one-purchase-order-inventaris/modules/po.js new file mode 100644 index 0000000..e468a93 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/modules/po.js @@ -0,0 +1,1470 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/po.js"; +import { validatePurchaseOrder, groupPurchaseRequestsByItemId, calculateSummaryTotal } from "../functions/functions.js"; + +export default { + namespaced: true, + state: { + statusOptions: [ + { value: 'All', title: "All" }, + { value: 'Draft', title: "Draft" }, + { value: 'Pending', title: "Pending" }, + { value: 'Approved', title: "Approved" }, + { value: 'Rejected', title: "Rejected" }, + { value: 'Completed', title: "Completed" }, + ], + selectedStatus: { value: 'All', title: "All" }, + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + search: '', + totalPage: 0, + selectedPage: 1, + loading: false, + poList: [ + { + "poNumber": "PO1234566", + "poDate": "01-01-2025", + "poVendor": "PT ABC 123", + "poTotal": "1000000", + "poStatus": "DRAFT", + } + ], + dialogForm: false, + detailData: [], + selectedPr: {}, + loadingDetail: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + //FORM + selectedDateForm: moment(new Date()).format('YYYY-MM-DD'), + selectedDateEnd: moment(new Date()).format('YYYY-MM-DD'), + selectedSupplier: {}, + refNumber: '', + taxPpn: 0, + taxPph: 0, + paymentTerm: 0, + discountType: 'Percentage', + discountTypeList: ['Percentage', 'Absolute'], + discountAmount: 0, + note: '', + warehouseTypeList: ['Single', 'Multiple'], + warehouseType: 'Single', + warehouseList: [], + selectedWarehouse: {}, + itemList: [], + selectedItemTemp: [], + selectedItem: [], + searchItem: '', + itemTotal: { + total: 0, + ppn: 0, + pph: 0, + tax: 0, + discount: 0, + finalTotal: 0, + }, + defaultWarehouse: {}, + shippingCost: 0, + shippingCostStatus: true,//Sudah di bayar atau belum + //END FORM + supplierList: [], + loadingAutocomplete: false, + searchSupplier: "", + dialogConfirmation: false, + dialogDelete: false, + selectedPO: {}, + dialogItem: false, + currentPageItem: 1, + totalPageItem: 0, + dialogFormAct: 'ADD', + summary: [], + summaryTotal: { + total: 0, + ppn: 0, + pph: 0, + tax: 0, + discount: 0, + finalTotal: 0, + }, + deletedItem: [],//kalau edit item sebelumnya yang dihapus masuk sini agar bisa dipilih lagi , + dialogView: false, + itemCategoryList: [], + selectedItemCategory: {}, + open_print: false, + // isValidMultipleWarehouse: false, // Flag untuk validasi multiple warehouse + isValidMultipleWarehouse: { + status: false, + message: '', + }, + riwayatPoList: [], + selected_riwayatPo: {}, + riwayatPoPage: 0, + dialogRiwayat: false, + currPageRiwayatPo: 1, + typePpn: ['Percentage', 'Absolute'], + typePpnSelected: 'Percentage', + }, + mutations: { + update_shippingCost(state, val) { + state.shippingCost = val; + }, + update_shippingCostStatus(state, val) { + state.shippingCostStatus = val; + }, + update_selectedItemCategory(state, val) { + state.selectedItemCategory = val; + }, + update_itemCategoryList(state, val) { + state.itemCategoryList = val; + }, + update_dialogView(state, val) { + state.dialogView = val; + }, + update_deletedItem(state, val) { + state.deletedItem = val; + }, + update_summaryTotal(state, val) { + state.summaryTotal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialogFormAct(state, val) { + state.dialogFormAct = val; + }, + update_totalPageItem(state, val) { + state.totalPageItem = val; + }, + update_currentPageItem(state, val) { + state.currentPageItem = val; + }, + update_dialogItem(state, val) { + state.dialogItem = val; + }, + update_selectedPO(state, val) { + state.selectedPO = val; + }, + update_dialogDelete(state, val) { + state.dialogDelete = val; + }, + update_dialogConfirmation(state, val) { + state.dialogConfirmation = val; + }, + update_defaultWarehouse(state, val) { + state.defaultWarehouse = val; + }, + update_itemTotal(state, val) { + state.itemTotal = val; + }, + update_searchItem(state, val) { + state.searchItem = val; + }, + update_selectedItemTemp(state, val) { + state.selectedItemTemp = val; + }, + update_selectedItem(state, val) { + state.selectedItem = val; + }, + update_itemList(state, val) { + state.itemList = val; + }, + update_warehouseList(state, val) { + state.warehouseList = val; + }, + update_supplierList(state, val) { + state.supplierList = val; + }, + update_searchSupplier(state, val) { + state.searchSupplier = val; + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + update_selectedWarehouse(state, val) { + state.selectedWarehouse = val; + }, + update_warehouseTypeList(state, val) { + state.warehouseTypeList = val; + }, + update_warehouseType(state, val) { + state.warehouseType = val; + // Disable and clear selectedWarehouse when type is Multiple + if (val === 'Multiple') { + state.selectedWarehouse = {}; + } + }, + update_note(state, val) { + state.note = val; + }, + update_discountAmount(state, val) { + // debugger; + if (state.discountType === 'Percentage' && val > 100) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Diskon tidak boleh lebih dari 100', + }; + state.discountAmount = 100; + return; + } + if (state.discountType === 'Absolute' && val > state.itemTotal.total && state.itemTotal.total > 0) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Diskon tidak boleh lebih dari total', + }; + state.discountAmount = state.itemTotal.total; + return; + } + state.discountAmount = val; + }, + update_discountType(state, val) { + state.discountType = val; + }, + update_paymentTerm(state, val) { + state.paymentTerm = val; + }, + update_taxPpn(state, val) { + if (state.typePpnSelected === 'Percentage' && val > 100) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Persen tidak boleh lebih dari 100', + }; + state.taxPpn = 100; + return; + } + if (state.typePpnSelected === 'Absolute' && val > state.itemTotal.total && state.itemTotal.total > 0) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Ppn tidak boleh lebih dari total', + }; + state.taxPpn = state.itemTotal.total; + return; + } + state.taxPpn = val; + // if (val > 0) { + // state.taxPpn = val; + // } else { + // state.taxPpn = 0; + // } + }, + update_taxPph(state, val) { + if (val > 0) { + state.taxPph = val; + } else { + state.taxPph = 0; + } + }, + update_refNumber(state, val) { + state.refNumber = val; + }, + update_selectedSupplier(state, val) { + state.selectedSupplier = val; + state.currPageRiwayatPo = 1 + }, + update_selectedDateForm(state, val) { + state.selectedDateForm = val; + }, + update_selectedDateEnd(state, val) { + state.selectedDateEnd = val; + }, + update_snackbar(state, val) { + state.snackbar = val; + }, + update_loadingDetail(state, val) { + state.loadingDetail = val; + }, + update_selectedPr(state, val) { + state.selectedPr = val; + }, + update_detailData(state, val) { + state.detailData = val; + }, + update_dialogForm(state, val) { + state.dialogForm = val; + }, + update_selectedStatus(state, val) { + state.selectedStatus = val; + }, + update_selectedDate(state, val) { + state.selectedDate = val; + }, + update_search(state, val) { + state.search = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_totalPage(state, val) { + state.totalPage = val; + }, + update_selectedPage(state, val) { + state.selectedPage = val; + }, + update_poList(state, val) { + state.poList = val; + }, + update_open_print(state, value) { + state.open_print = value + }, + update_isValidMultipleWarehouse(state, value) { + state.isValidMultipleWarehouse = value; + }, + update_riwayatPoList(state, val) { + state.riwayatPoList = val; + }, + update_selected_riwayatPo(state, val) { + state.selected_riwayatPo = val; + }, + update_riwayatPoPage(state, val) { + state.riwayatPoPage = val; + }, + update_dialogRiwayat(state, val) { + state.dialogRiwayat = val; + }, + update_currPageRiwayatPo(state, val) { + state.currPageRiwayatPo = val; + }, + update_typePpn(state, val) { + state.typePpn = val; + }, + update_typePpnSelected(state, val) { + state.typePpnSelected = val; + }, + }, + actions: { + deleteItemFromSummary(context, { itemId = null, detailId = null }) { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = context.state.summary.filter(item => item.keyID !== itemId); + const newSelectedItem = context.state.selectedItem.filter(item => item.keyID !== itemId); + if (context.state.dialogFormAct === 'EDIT') { + let deletedItemBefore = JSON.parse(JSON.stringify(context.state.deletedItem)) + const deletedItem = context.state.selectedItem.filter(item => item.keyID === itemId + && item.PurchaseOrderDetailID !== undefined + && item.PurchaseOrderDetailID !== null + && item.PurchaseOrderDetailID !== 0); + let newDeletedItem = [] + deletedItem.forEach(de => { + let cek = deletedItemBefore.find((element) => + element.M_ItemID === de.M_ItemID + && element.PurchaseRequestFlagID === de.PurchaseRequestFlagID + && element.PurchaseOrderDetailID === de.PurchaseOrderDetailID) + if (!cek) { + newDeletedItem.push(de) + } + }); + context.commit('update_deletedItem', [...deletedItemBefore, ...newDeletedItem]); + } + + const newRef = newSelectedItem.map(obj => obj.PurchaseRequestNumber).join(", "); + + context.commit("update_refNumber", newRef); + context.commit('update_summary', newSummary); + context.commit('update_selectedItem', newSelectedItem); + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = context.state.selectedItem.filter( + item => item.PurchaseRequestFlagID !== detailId + ); + if (context.state.dialogFormAct === 'EDIT') { + let deletedItemBefore = JSON.parse(JSON.stringify(context.state.deletedItem)) + const deletedItem = context.state.selectedItem.filter( + item => item.PurchaseRequestFlagID === detailId + && item.PurchaseOrderDetailID !== undefined + && item.PurchaseOrderDetailID !== null + && item.PurchaseOrderDetailID !== 0 + ); + let newDeletedItem = [] + deletedItem.forEach(de => { + let cek = deletedItemBefore.find((element) => + element.M_ItemID === de.M_ItemID + && element.PurchaseRequestFlagID === de.PurchaseRequestFlagID + && element.PurchaseOrderDetailID === de.PurchaseOrderDetailID) + if (!cek) { + newDeletedItem.push(de) + } + }); + context.commit('update_deletedItem', [...deletedItemBefore, ...newDeletedItem]); + } + + // Regenerate summary dari selectedItem yang baru + const newSummary = groupPurchaseRequestsByItemId(newSelectedItem); + const newRef = newSelectedItem.map(obj => obj.PurchaseRequestNumber).join(", "); + + context.commit("update_refNumber", newRef); + context.commit('update_summary', newSummary); + context.commit('update_selectedItem', newSelectedItem); + } + + // Hitung ulang total + context.dispatch('countItemTotal'); + context.dispatch('generateSummary'); + }, + + generateSummaryTotal(context) { + const summaryTotal = calculateSummaryTotal( + context.state.summary, + context.state.typePpnSelected, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + context.commit('update_summaryTotal', summaryTotal); + }, + + generateSummary(context) { + let data = JSON.parse(JSON.stringify(context.state.selectedItem)); + console.log("Data untuk param groupPurchaseRequestsByItemId:", JSON.parse(JSON.stringify(data))); + + /** + * Tambah validasi: + * > Apakah bisa multiple warehouse? + */ + context.dispatch('isValidMultipleWarehouse'); + + if (context.state.warehouseType === "Multiple") { + data.forEach((element) => { + element.warehouse = { + WarehouseID: element.WarehouseID, + WarehouseName: element.WarehouseName, + }; + }); + } else if (context.state.warehouseType === "Single") { + data.forEach((element) => { + element.warehouse = context.state.selectedWarehouse; // Semua item pakai warehouse yang sama + }); + } + + let summary = groupPurchaseRequestsByItemId(data); + context.commit('update_summary', summary); + console.log("Summary setelah grouping:", JSON.parse(JSON.stringify(summary))); + + // Hitung summary total menggunakan fungsi dari functions.js + const summaryTotal = calculateSummaryTotal( + summary, + context.state.typePpnSelected, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + }, + + multipleWarehouseValidation(context, selectedItem) { + let data; + + if (!selectedItem || selectedItem.length === 0) { + data = JSON.parse(JSON.stringify(context.state.selectedItem)); + } else { + data = JSON.parse(JSON.stringify(selectedItem)); + } + + // Pakai 'Set' JS Object yang hanya menyimpan nilai unik. + const warehouseIds = new Set(); + + data.forEach(item => { + if (item.WarehouseID) { + // Kalau ada yang sama maka disimpan sekali. + warehouseIds.add(item.WarehouseID); + } + }); + + if (warehouseIds.size > 1) { + return true; // Ada lebih dari satu WarehouseID + } else { + return false; // Hanya ada satu WarehouseID + } + }, + + async isValidMultipleWarehouse(context) { + /** + * @param: array of PurchaseRequestDetailID dari selectedItem + * @api: api.isValidMultipleWarehouse + * @return: JSON -> {data.status (boolean), data.message (string)} + * + */ + if (context.state.selectedItem.length === 0) { + return false; // Tidak ada item yang dipilih + } + try { + let payload = { + "PurchaseRequestDetailIDs": context.state.selectedItem.map(item => item.PurchaseRequestDetailID), + "token": one_token(), + }; + + let response = await api.isValidMultipleWarehouse(payload) + + // console.log("Payload untuk isValidMultipleWarehouse:", JSON.parse(JSON.stringify(payload.PurchaseRequestDetailIDs))); + // console.log("Response dari isValidMultipleWarehouse:", JSON.parse(JSON.stringify(response))); + + if (response.status !== "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_isValidMultipleWarehouse", { + status: false, + message: '', + }); + context.commit("update_snackbar", snackbar); + } else {; + context.commit("update_isValidMultipleWarehouse", { + status: response.data.status, + message: response.data.message, + }); + if(response.data.status == false) { + context.commit("update_warehouseType", 'Single'); + context.commit("update_selectedWarehouse", context.state.selectedWarehouse); + } + }; + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + } + }, + + assignEdit(context) { + let data = context.state.selectedPO + context.commit("update_selectedDateForm", data.PurchaseOrderDate); + context.commit("update_searchSupplier", data.SupplierName); + context.commit("update_selectedSupplier", { + "SupplierID": data.PurchaseOrderSupplierID, + "SupplierCode": data.SupplierCode, + "SupplierName": data.SupplierName + }); + context.commit("update_selectedItemCategory", { + "itemCategoryID": data.itemCategoryID, + "itemCategoryName": data.itemCategoryName + }); + context.commit("update_refNumber", data.PurchaseOrderRefNumber); + context.commit("update_shippingCost", data.PurchaseOrderShippingCost); + context.commit("update_shippingCostStatus", data.PurchaseOrderShippingCostStatus === 'Y' ? true : false); + context.commit("update_typePpnSelected", data.PurchaseOrderTaxPercentPpn > 0 ? 'Percentage' : 'Absolute'); + if (data.PurchaseOrderTaxPercentPpn > 0) { + context.commit("update_taxPpn", parseFloat(data.PurchaseOrderTaxPercentPpn)); + } else { + context.commit("update_taxPpn", parseFloat(data.PurchaseOrderTaxAmountPpn)); + } + context.commit("update_taxPph", data.PurchaseOrderTaxPercentPph); + context.commit("update_paymentTerm", data.PurchaseOrderPaymentTerm); + context.commit("update_discountType", data.PurchaseOrderDiscountPercent > 0 ? 'Percentage' : 'Absolute'); + if (data.PurchaseOrderDiscountPercent > 0) { + context.commit("update_discountAmount", parseFloat(data.PurchaseOrderDiscountPercent)); + } else { + context.commit("update_discountAmount", parseFloat(data.PurchaseOrderDiscountAmount)); + } + context.commit("update_note", data.PurchaseOrderNote); + context.commit("update_warehouseType", data.PurchaseOrderWarehouseType); + context.commit("update_selectedWarehouse", { + "WarehouseID": data.PurchaseOrderWarehouseID, + "WarehouseCode": data.WarehouseCode, + "WarehouseName": data.WarehouseName, + }); + context.commit("update_dialogFormAct", 'EDIT'); + context.dispatch("countItemTotal"); + }, + + async resetForm(context) { + context.commit("update_selectedDateForm", moment(new Date()).format('YYYY-MM-DD')); + context.commit("update_selectedSupplier", {}); + context.commit("update_selectedWarehouse", {}); + context.commit("update_defaultWarehouse", {}); + context.commit("update_warehouseType", 'Single'); + context.commit("update_refNumber", ''); + context.commit("update_taxPpn", 0); + context.commit("update_typePpnSelected", 'Percentage'); + context.commit("update_taxPph", 0); + context.commit("update_paymentTerm", 0); + context.commit("update_discountType", 'Percentage'); + context.commit("update_discountAmount", 0); + context.commit("update_note", ''); + + context.commit("update_selectedItemTemp", []); + context.commit("update_selectedItem", []); + context.commit("update_deletedItem", []); + context.commit("update_summary", []); + + context.commit("update_shippingCost", 0); + context.commit("update_shippingCostStatus", true); + + context.commit("update_itemList", []); + context.commit("update_searchItem", ''); + + context.commit("update_warehouseList", []); + context.commit("update_searchSupplier", 'null'); + context.commit("update_supplierList", []); + context.commit("update_dialogFormAct", 'ADD'); + context.commit("update_summaryTotal", { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }); + context.commit("update_itemTotal", { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }); + }, + + countItemTotal(context) { + let selectedItem = context.state.selectedItem; + if (selectedItem.length === 0) { + let hasil = { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + } + context.commit("update_itemTotal", hasil); + return; + } + + // Fix: Ensure we're working with numeric values + let total = selectedItem.reduce((acc, item) => { + // Convert string to number if needed + const itemTotal = typeof item.Total === 'string' ? + parseFloat(item.Total.replace(/\./g, '').replace(',', '.')) : + item.Total; + return acc + (isNaN(itemTotal) ? 0 : itemTotal); + }, 0); + + total = Math.round(total * 100) / 100; + + let discount = parseFloat(context.state.discountAmount) || 0; + if (context.state.discountType === 'Percentage') { + discount = Math.round((discount / 100) * total * 100) / 100; + } + + let newTotal = Math.round((total - discount) * 100) / 100; + + let ppn = 0; + if (context.state.typePpnSelected === 'Absolute') { + ppn = context.state.taxPpn; + } else { + ppn = Math.round((parseFloat(context.state.taxPpn) / 100) * newTotal * 100) / 100; + } + + let pph = Math.round((parseFloat(context.state.taxPph) / 100) * newTotal * 100) / 100; + let pajak = Math.round((ppn + pph) * 100) / 100; + let final = Math.round((newTotal + pajak) * 100) / 100; + + let hasil = { + total: total, + tax: pajak, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: final, + } + context.commit("update_itemTotal", hasil); + }, + + updatePoQty(context, { itemId, newPoQty }) { + let updatedSelectedItem = context.state.selectedItem.map(item => { + if (item.PurchaseRequestFlagID === itemId) { + // Convert string to number and ensure minimum value of 1 + const numericPoQty = Number(newPoQty); + item.PoQty = Math.max(1, Math.floor(isNaN(numericPoQty) ? 1 : numericPoQty)); + + // Recalculate item total + let price = item.DefaultPurchase?.SupplierPricePrice || 0; + + // Apply discount if exists + if (item.discount > 0) { + if (item.discountType === 'P') { + price = price - (item.discount * price / 100); + } else if (item.discountType === 'R') { + price = price - item.discount; + } + } + + item.Total = item.PoQty * price; + } + return item; + }); + + context.commit('update_selectedItem', updatedSelectedItem); + + // Regenerate summary + context.dispatch('generateSummary'); + context.dispatch('countItemTotal'); + context.dispatch('generateSummaryTotal'); + }, + + async getSupplier(context) { + if (context.state.searchSupplier.length < 2) return; + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + token: one_token(), + search: context.state.searchSupplier, + + }; + + let response = await api.getSupplier(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_supplierList", data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getItemCategory(context) { + + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + token: one_token(), + + }; + + let response = await api.getItemCategory(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_itemCategoryList", data.records); + context.commit("update_selectedItemCategory", { + "itemCategoryID": data.records[0].itemCategoryID, + "itemCategoryName": data.records[0].itemCategoryName + }); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getWarehouse(context) { + + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + regionalId: one_user().S_RegionalID, + categoryID: context.state.selectedItemCategory.itemCategoryID, + token: one_token(), + }; + + let response = await api.getWarehouse(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + response.data.records.forEach(element => { + if (element.WarehouseIsDefault === 'Y') { + if (context.state.dialogFormAct != 'EDIT') { + context.commit("update_defaultWarehouse", element); + context.commit("update_selectedWarehouse", element); + } + } + + }); + context.commit("update_warehouseList", response.data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getItem(context) { + context.commit("update_loading", true); + try { + var payload = { + "search": context.state.searchItem, + "currentPage": context.state.currentPageItem, + "supplierID": context.state.selectedSupplier.SupplierID, + "itemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "regionalId": one_user().S_RegionalID, + "token": one_token(), + }; + + let response = await api.getItem(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_itemList", data.records); + context.commit("update_totalPageItem", data.total); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getItemUpdate(context) { + context.commit("update_loading", true); + try { + var payload = { + "POID": context.state.selectedPO.PurchaseOrderID, + "token": one_token(), + }; + + let response = await api.getItemUpdate(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_selectedItem", data.records); + /** + * Tambah validasi: + * > Apakah bisa multiple warehouse? + */ + context.dispatch('isValidMultipleWarehouse'); + + context.commit("update_summary", response.data.summary) + context.dispatch("countItemTotal"); + // Hitung summary total menggunakan fungsi dari functions.js + // TODO: Check ini akibat penyesuaian + const summaryTotal = calculateSummaryTotal( + response.data.summary, + context.state.typePpnSelected, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async saveOrder(context) { + try { + if (!validatePurchaseOrder(context)) { + return; + } + + const invalidQtyItems = context.state.selectedItem.filter(item => { + // Convert string to number first + const poQty = Number(item.PoQty); + + // Check if conversion failed (NaN), is less than 1, or not an integer + return isNaN(poQty) || poQty < 1 || !Number.isInteger(poQty); + }); + + if (invalidQtyItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki quantity minimal 1", + } + context.commit("update_snackbar", snackbar); + return; + } + + const invalidPriceItems = context.state.selectedItem.filter(item => { + const Price = Number(item.Price); + return isNaN(Price) || Price <= 0; + }); + + if (invalidPriceItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki harga", + } + context.commit("update_snackbar", snackbar); + return; + } + + context.commit("update_loading", true); + + // menambahkan pengecekan tax ppn 19-12-2025 + // jika ppn persen maka masuk ke tax persentppn + // jika ppn absolute maka masuk ke tax amount ppn + let ppnPercent = 0; + if (context.state.typePpnSelected === 'Percentage') { + ppnPercent = context.state.taxPpn; + } + + var payload = { + "token": one_token(), + "Date": context.state.selectedDateForm, + "RefNumber": context.state.refNumber, + "SupplierID": context.state.selectedSupplier.SupplierID, + "ItemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "TaxPpnType": context.state.typePpnSelected === 'Percentage' ? 'P' : 'R', + "TaxPercent": ppnPercent, + "PaymentTerm": context.state.paymentTerm, + "DiscountPercent": context.state.discountType === 'Percentage' ? context.state.discountAmount : 0, + "DiscountAmount": context.state.discountType === 'Absolute' ? context.state.discountAmount : 0, + "WarehouseType": context.state.warehouseType, + "WarehouseID": context.state.selectedWarehouse.WarehouseID, + "Note": context.state.note, + "SubTotal": context.state.summaryTotal.total, + "TaxPercentPph": context.state.taxPph, + "TaxPercentPpn": ppnPercent, + "TaxAmount": context.state.summaryTotal.tax, + "TaxAmountPph": context.state.summaryTotal.pph, + "TaxAmountPpn": context.state.summaryTotal.ppn, + "GrandTotal": context.state.summaryTotal.finalTotal, + "ShippingCost": context.state.shippingCost, + "ShippingCostStatus": context.state.shippingCostStatus, + // "Details": detail, + "Summary": context.state.summary + }; + + console.log("Payload untuk saveOrder:", JSON.parse(JSON.stringify(payload))); + + // Validasi Total Tidak Boleh <0 + const financialChecks = [ + { value: payload.GrandTotal, name: "Total" }, + { value: payload.SubTotal, name: "Sub Total" }, + { value: payload.TaxAmount, name: "Pajak" }, + { value: payload.TaxAmountPph, name: "Pajak PPH" }, + { value: payload.TaxAmountPpn, name: "Pajak PPN" }, + { value: payload.DiscountAmount, name: "Diskon" }, + { value: payload.ShippingCost, name: "Biaya Ekspedisi" } + ]; + + for (const check of financialChecks) { + if (check.value < 0) { + let snackbar = { + state: true, + type: "error", + message: `${check.name} tidak boleh kurang dari 0`, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + return; + } + } + + let response = await api.saveOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil simpan data", + } + context.commit("update_snackbar", snackbar); + + + context.commit("update_loading", false); + context.commit("update_dialogForm", false); + context.dispatch("resetForm"); + context.dispatch("searchData"); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async searchData(context) { + context.commit("update_loading", true); + try { + var url_string = window.location.href + var url = new URL(url_string); + var xdate = url.searchParams.get("date"); + var xsearch = url.searchParams.get("search"); + + if (xsearch) { + context.commit("update_search", xsearch); + } + if (xdate) { + context.commit("update_selectedDate", xdate); + context.commit("update_selectedDateEnd", xdate); + } + + var payload = { + "token": one_token(), + "currentPage": context.state.selectedPage, + "search": context.state.search, + "startDate": context.state.selectedDate, + "endDate": context.state.selectedDateEnd, + "status": context.state.selectedStatus.value, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("update_totalPage", response.data.totalPage); + context.commit("update_poList", data.records); + context.commit("update_loading", false); + context.dispatch("system/getlistnotif", null, { root: true }) + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async requestOrder(context) { + context.commit("update_loading", true); + + try { + + var payload = { + "token": one_token(), + "ID": context.state.selectedPO.PurchaseOrderID, + }; + + let response = await api.requestOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil request order", + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + context.commit("update_dialogConfirmation", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async deleteOrder(context) { + context.commit("update_loading", true); + + try { + var payload = { + "token": one_token(), + "PurchaseOrderId": context.state.selectedPO.PurchaseOrderID, + }; + + let response = await api.deleteOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil hapus order", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + context.commit("update_dialogDelete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async updateOrder(context) { + try { + if (!validatePurchaseOrder(context)) { + return; + } + + const invalidQtyItems = context.state.selectedItem.filter(item => { + // Convert string to number first + const poQty = Number(item.PoQty); + + // Check if conversion failed (NaN), is less than 1, or not an integer + return isNaN(poQty) || poQty < 1 || !Number.isInteger(poQty); + }); + + // console.log("InvalidQtyItem updateOrder", invalidQtyItems) + + if (invalidQtyItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki quantity minimal 1", + } + context.commit("update_snackbar", snackbar); + return; + } + + const invalidPriceItems = context.state.selectedItem.filter(item => { + const Price = Number(item.Price); + return isNaN(Price) || Price <= 0; + }); + + if (invalidPriceItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki harga", + } + context.commit("update_snackbar", snackbar); + return; + } + + // menambahkan pengecekan tax ppn 19-12-2025 + // jika ppn persen maka masuk ke tax persentppn + // jika ppn absolute maka masuk ke tax amount ppn + let ppnPercent = 0; + if (context.state.typePpnSelected === 'Percentage') { + ppnPercent = context.state.taxPpn; + } + + var payload = { + "token": one_token(), + "Date": context.state.selectedDateForm, + "RefNumber": context.state.refNumber, + "SupplierID": context.state.selectedSupplier.SupplierID, + "TaxPpnType": context.state.typePpnSelected === 'Percentage' ? 'P' : 'R', + "TaxPercent": ppnPercent, + "PaymentTerm": context.state.paymentTerm, + "ItemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "DiscountPercent": context.state.discountType === 'Percentage' ? context.state.discountAmount : 0, + "DiscountAmount": context.state.discountType === 'Absolute' ? context.state.discountAmount : 0, + "WarehouseType": context.state.warehouseType, + "WarehouseID": context.state.selectedWarehouse.WarehouseID, + "Note": context.state.note, + "SubTotal": context.state.summaryTotal.total, + "TaxPercentPph": context.state.taxPph, + "TaxPercentPpn": ppnPercent, + "TaxAmount": context.state.summaryTotal.tax, + "TaxAmountPph": context.state.summaryTotal.pph, + "TaxAmountPpn": context.state.summaryTotal.ppn, + "GrandTotal": context.state.summaryTotal.finalTotal, + "ShippingCost": context.state.shippingCost, + "ShippingCostStatus": context.state.shippingCostStatus, + "PO": context.state.selectedPO, + "Summary": context.state.summary, + "deletedItem": context.state.deletedItem + }; + + // Validasi Total Tidak Boleh <0 + const financialChecks = [ + { value: payload.GrandTotal, name: "Total" }, + { value: payload.SubTotal, name: "Sub Total" }, + { value: payload.TaxAmount, name: "Pajak" }, + { value: payload.TaxAmountPph, name: "Pajak PPH" }, + { value: payload.TaxAmountPpn, name: "Pajak PPN" }, + { value: payload.DiscountAmount, name: "Diskon" }, + { value: payload.ShippingCost, name: "Biaya Ekspedisi" } + ]; + + for (const check of financialChecks) { + if (check.value < 0) { + let snackbar = { + state: true, + type: "error", + message: `${check.name} tidak boleh kurang dari 0`, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + return; + } + } + + context.commit("update_loading", true); + let response = await api.updateOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil simpan data", + } + context.commit("update_snackbar", snackbar); + + + context.commit("update_loading", false); + context.commit("update_dialogForm", false); + context.dispatch("resetForm"); + context.dispatch("searchData"); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async approveOrder(context, payload) { + context.commit("update_loading", true); + try { + payload.token = one_token() + + let response = await api.approvePOrder(payload); + if (response.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let params = { token: one_token(), id: payload.poID } + let generateitempo = await api.generateItemPO(params) + if (generateitempo.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let snackbar = { + state: true, + type: "success", + message: "Berhasil approve order", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + } + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getPoBySupplier(context) { + context.commit("update_loading", true); + + try { + var payload = { + token: one_token(), + supplierID: context.state.selectedSupplier.SupplierID, + currentPage: context.state.currPageRiwayatPo, + + }; + + let response = await api.getPoBySupplier(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + totalPage: response.data.totalPage, + }; + + + context.commit("update_riwayatPoList", data.records); + context.commit("update_riwayatPoPage", data.totalPage); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + }, +}; diff --git a/test/vuex/acc-one-purchase-order-inventaris/store.js b/test/vuex/acc-one-purchase-order-inventaris/store.js new file mode 100644 index 0000000..e107174 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-inventaris/store.js @@ -0,0 +1,14 @@ +// import manager from "./modules/manager.js"; +// import prkacab from "./modules/prkacab.js" +import system from "../../../apps/modules/system/system.js"; +import po from "./modules/po.js"; + +export const store = new Vuex.Store({ + modules: { + po: po, + system: system + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-purchase-order-v2/api/po.js b/test/vuex/acc-one-purchase-order-v2/api/po.js new file mode 100644 index 0000000..1cf4a1b --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/api/po.js @@ -0,0 +1,293 @@ +const URL = "/one-api/mockup/purchase/order/PurchaseOrderV2/"; +const URLRO = "/one-api/mockup/receive-item-po/receiveitempo/"; + +export async function getSupplier(payload) { + try { + var response = await axios.post(URL + "getSupplier", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItemCategory(payload) { + try { + var response = await axios.post(URL + "getItemCategory", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getWarehouse(payload) { + try { + var response = await axios.post(URL + "getWarehouse", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItem(payload) { + try { + var response = await axios.post(URL + "getItem", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getItemUpdate(payload) { + try { + var response = await axios.post(URL + "getItemUpdate", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function saveOrder(payload) { + try { + var response = await axios.post(URL + "saveOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function search(payload) { + try { + var response = await axios.post(URL + "search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function requestOrder(payload) { + try { + var response = await axios.post(URL + "requestOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteOrder(payload) { + try { + var response = await axios.post(URL + "deleteOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateOrder(payload) { + try { + var response = await axios.post(URL + "updateOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approvePOrder(payload) { + try { + var response = await axios.post(URL + "approvePOrder", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function isValidMultipleWarehouse(payload) { + try { + var response = await axios.post(URL + "isValidMultipleWarehouse", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getPoBySupplier(payload) { + try { + var response = await axios.post(URL + "getPoBySupplier", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function generateItemPO(params) { + try { + var response = await axios.post(URLRO + "generateItemPo", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getDefaultSupplierPrice(payload) { + try { + var response = await axios.post(URL + "getDefaultSupplierPrice", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-v2/components/dialogRiwayatPo.vue b/test/vuex/acc-one-purchase-order-v2/components/dialogRiwayatPo.vue new file mode 100644 index 0000000..9824cb0 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/components/dialogRiwayatPo.vue @@ -0,0 +1,308 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-v2/components/dialogView.vue b/test/vuex/acc-one-purchase-order-v2/components/dialogView.vue new file mode 100644 index 0000000..6ff7f41 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/components/dialogView.vue @@ -0,0 +1,593 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-v2/components/po.vue b/test/vuex/acc-one-purchase-order-v2/components/po.vue new file mode 100644 index 0000000..2d40e1c --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/components/po.vue @@ -0,0 +1,655 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-v2/components/poForm.vue b/test/vuex/acc-one-purchase-order-v2/components/poForm.vue new file mode 100644 index 0000000..e79fa47 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/components/poForm.vue @@ -0,0 +1,1642 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-v2/components/poForm_bckp.vue b/test/vuex/acc-one-purchase-order-v2/components/poForm_bckp.vue new file mode 100644 index 0000000..0d2f234 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/components/poForm_bckp.vue @@ -0,0 +1,1761 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-order-v2/functions/functions-pra-multiple-gudang-boleh-null.js b/test/vuex/acc-one-purchase-order-v2/functions/functions-pra-multiple-gudang-boleh-null.js new file mode 100644 index 0000000..de62aa7 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/functions/functions-pra-multiple-gudang-boleh-null.js @@ -0,0 +1,396 @@ +/** + * Utility functions for the ACC One Purchase Order application + */ + +// /** +// * Groups an array of objects by a specified key +// * @param {Array} array - The array of objects to group +// * @param {String} key - The key to group by +// * @returns {Object} - An object with keys representing the grouped values and arrays as values +// */ +// export const groupBy = (array, key) => { +// return array.reduce((result, item) => { +// const groupKey = item[key]; +// if (!result[groupKey]) { +// result[groupKey] = []; +// } +// result[groupKey].push(item); +// return result; +// }, {}); +// }; +/** + * Groups an array of objects by one or multiple keys + * @param {Array} array - The array of objects to group + * @param {Function|String|Array} key - The key(s) to group by. Can be a string, array of strings, or a function. + * @returns {Object} - An object with keys representing the grouped values and arrays as values + */ +export const groupBy = (array, key) => { + return array.reduce((result, item) => { + let groupKey; + + // Handle single key (string), multiple keys (array), or custom function + if (typeof key === 'function') { + groupKey = key(item); + } else if (Array.isArray(key)) { + groupKey = key.map(k => item[k]).join('_'); // Combine multiple keys with underscore + } else { + groupKey = item[key]; + } + + if (!result[groupKey]) { + result[groupKey] = []; + } + result[groupKey].push(item); + return result; + }, {}); +}; + +/** + * Groups purchase request data by M_ItemID + * @param {Array} purchaseRequestData - Array of purchase request objects + * @returns {Array} - Array of objects with M_ItemID, M_ItemCode, M_ItemDesc, unit information, converted PoQty, and Details array + */ +export const groupPurchaseRequestsByItemId = (purchaseRequestData) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'ItemUnitID']); + console.log("grouped"); + console.log(grouped); + + return Object.keys(grouped).map(itemId => { + const items = grouped[itemId]; + const firstItem = items[0]; + + // Calculate total PoQty from all items + const totalPoQty = calculateTotalQuantity(items, 'PoQty'); + + // Get the conversion factor from the first item + const conversionFactor = Number(firstItem.DefaultPurchase.UnitConvertAmount) || 1; + + // Convert the total quantity and round up if it's a decimal + const convertedPoQty = Math.ceil(convertUnits(totalPoQty, conversionFactor)); + + let price = 0; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - (Number(firstItem.discount) * (Number(firstItem.DefaultPurchase.SupplierPricePrice) / 100)); + } + if (firstItem.discountType === 'R') { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - Number(firstItem.discount); + } + + } else { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + } + + // Get the price from the first item + const realPrice = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + + // Calculate the total (PoQty * price) + const total = convertedPoQty * price; + + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + + + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + ItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + ItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + PoQty: convertedPoQty, + Price: price, + RealPrice: realPrice, + PriceAfterDiscount: price, + Total: total, + Details: items + }; + }); +}; + +/** + * Formats a number as currency (IDR) + * @param {Number} amount - The amount to format + * @returns {String} - Formatted currency string + */ +export const formatCurrency = (amount) => { + return new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }).format(amount); +}; + +/** + * Formats a date to a localized string + * @param {Date|String} date - The date to format + * @param {Object} options - Intl.DateTimeFormat options + * @returns {String} - Formatted date string + */ +export const formatDate = (date, options = { + year: 'numeric', + month: 'long', + day: 'numeric' +}) => { + if (!date) return ''; + const dateObj = typeof date === 'string' ? new Date(date) : date; + return new Intl.DateTimeFormat('id-ID', options).format(dateObj); +}; + +/** + * Calculates the total value of purchase requests + * @param {Array} items - Array of purchase request items + * @returns {Number} - Total value + */ +export const calculateTotal = (items) => { + return items.reduce((sum, item) => sum + (Number(item.Total) || 0), 0); +}; + +/** + * Calculates the total quantity of items + * @param {Array} items - Array of purchase request items + * @param {String} qtyField - The field name containing quantity (e.g., 'RequestQty', 'FlagQty', 'PoQty') + * @returns {Number} - Total quantity + */ +export const calculateTotalQuantity = (items, qtyField = 'RequestQty') => { + return items.reduce((sum, item) => sum + (Number(item[qtyField]) || 0), 0); +}; + +/** + * Converts units based on the conversion factor + * @param {Number} quantity - The quantity to convert + * @param {Number} conversionFactor - The conversion factor + * @returns {Number} - Converted quantity + */ +export const convertUnits = (quantity, conversionFactor) => { + return quantity / conversionFactor; +}; + +/** + * Filters purchase requests by branch + * @param {Array} items - Array of purchase request items + * @param {String|Array} branchCodes - Branch code(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByBranch = (items, branchCodes) => { + if (!branchCodes) return items; + + const codes = Array.isArray(branchCodes) ? branchCodes : [branchCodes]; + return items.filter(item => codes.includes(item.BranchCode)); +}; + +/** + * Filters purchase requests by regional + * @param {Array} items - Array of purchase request items + * @param {String|Array} regionalIds - Regional ID(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByRegional = (items, regionalIds) => { + if (!regionalIds) return items; + + const ids = Array.isArray(regionalIds) ? regionalIds : [regionalIds]; + return items.filter(item => ids.includes(item.S_RegionalID)); +}; + +/** + * Validates if a purchase request item has all required fields + * @param {Object} item - Purchase request item + * @returns {Boolean} - True if valid, false otherwise + */ +export const validatePurchaseRequestItem = (item) => { + const requiredFields = [ + 'M_ItemID', + 'M_ItemCode', + 'M_ItemDesc', + 'Price', + 'RequestQty' + ]; + + return requiredFields.every(field => item[field] !== undefined && item[field] !== null); +}; + +/** + * Sorts purchase request items by a specified field + * @param {Array} items - Array of purchase request items + * @param {String} field - Field to sort by + * @param {Boolean} ascending - Sort direction (true for ascending, false for descending) + * @returns {Array} - Sorted items + */ +export const sortPurchaseRequests = (items, field = 'M_ItemDesc', ascending = true) => { + return [...items].sort((a, b) => { + const valueA = a[field]; + const valueB = b[field]; + + if (typeof valueA === 'string' && typeof valueB === 'string') { + return ascending + ? valueA.localeCompare(valueB) + : valueB.localeCompare(valueA); + } + + return ascending + ? (valueA - valueB) + : (valueB - valueA); + }); +}; + +/** + * Validates purchase order data before saving + * @param {Object} context - Vuex context object + * @returns {Boolean} - Returns true if validation passes, false otherwise + */ +export const validatePurchaseOrder = (context) => { + if (context.state.loading) { + let snackbar = { + state: true, + type: "warning", + message: 'Loading sedang berlangsung harap menunggu ...', + }; + context.commit("update_snackbar", snackbar); + return false; + } + + let warningMsg = []; + if (context.state.selectedItem.length == 0) { + warningMsg.push('Belum memilih item'); + } + if (!context.state.selectedWarehouse || !context.state.selectedWarehouse.WarehouseID) { + warningMsg.push('Gudang belum dipilih'); + } + if (!context.state.selectedSupplier || !context.state.selectedSupplier.SupplierID) { + warningMsg.push('Supplier belum dipilih'); + } + if (context.state.discountType === 'Percentage') { + const discountValue = (context.state.itemTotal.total * context.state.discountAmount) / 100; + if (discountValue > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } else if (context.state.discountType === 'Absolute') { + if (context.state.discountAmount > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } + + context.state.summary.forEach(element => { + if (Number(element.discount) < 0) { + warningMsg.push('Diskon ' + element.M_ItemDesc + ' tidak boleh kurang dari 0'); + } + if (element.discountType === 'P') { + if (Number(element.discount) > 100) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi 100'); + } + } + if (element.discountType === 'R') { + if (Number(element.discount) > Number(element.RealPrice)) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi dari harga'); + } + } + }); + + if (warningMsg.length > 0) { + let snackbar = { + state: true, + type: "warning", + message: warningMsg.join(", "), + }; + context.commit("update_snackbar", snackbar); + return false; + } + + return true; +}; + +/** + * Menghitung total summary untuk purchase order + * @param {Array} summary - Array data summary + * @param {Number} taxPpn - Persentase pajak PPN + * @param {Number} taxPph - Persentase pajak PPH + * @param {String} discountType - Tipe diskon ('Percentage' atau 'Absolute') + * @param {Number} discountAmount - Jumlah diskon + * @returns {Object} - Object summaryTotal + */ +export const calculateSummaryTotal = (summary, taxPpn = 0, taxPph = 0, discountType = 'Percentage', discountAmount = 0) => { + if (!summary || summary.length === 0) { + return { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }; + } + + // Hitung total dari item summary + const total = summary.reduce((acc, item) => acc + (Number(item.Total) || 0), 0); + + // Hitung diskon berdasarkan tipe + let discount = discountAmount; + if (discountType === 'Percentage') { + discount = (discountAmount / 100) * total; + } + + // Hitung pajak + const newTotal = total - discount; + const ppn = (taxPpn / 100) * newTotal; + const pph = (taxPph / 100) * newTotal; + const tax = ppn + pph; + const finalTotal = newTotal + tax; + + // Return object summaryTotal + return { + total: total, + tax: tax, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: finalTotal, + }; +}; + + +/** + * Menghapus item dari summary dan selectedItem berdasarkan itemId atau detailId + * @param {Array} summary - Array data summary + * @param {Array} selectedItem - Array data selectedItem + * @param {String} itemId - ID item yang akan dihapus (opsional) + * @param {String} detailId - ID detail yang akan dihapus (opsional) + * @returns {Object} - Object berisi summary dan selectedItem yang sudah diupdate + */ +export const deleteItemFromSummary = (summary, selectedItem, itemId = null, detailId = null) => { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = summary.filter(item => item.M_ItemID !== itemId); + const newSelectedItem = selectedItem.filter(item => item.M_ItemID !== itemId); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = selectedItem.filter(item => item.PurchaseRequestFlagID !== detailId); + + // Regenerate summary dari selectedItem yang baru + const newSummary = groupPurchaseRequestsByItemId(newSelectedItem); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + return { + summary, + selectedItem + }; +}; \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-v2/functions/functions.js b/test/vuex/acc-one-purchase-order-v2/functions/functions.js new file mode 100644 index 0000000..e7ce731 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/functions/functions.js @@ -0,0 +1,543 @@ +/** + * Utility functions for the ACC One Purchase Order application + */ + +// /** +// * Groups an array of objects by a specified key +// * @param {Array} array - The array of objects to group +// * @param {String} key - The key to group by +// * @returns {Object} - An object with keys representing the grouped values and arrays as values +// */ +// export const groupBy = (array, key) => { +// return array.reduce((result, item) => { +// const groupKey = item[key]; +// if (!result[groupKey]) { +// result[groupKey] = []; +// } +// result[groupKey].push(item); +// return result; +// }, {}); +// }; +/** + * Groups an array of objects by one or multiple keys + * @param {Array} array - The array of objects to group + * @param {Function|String|Array} key - The key(s) to group by. Can be a string, array of strings, or a function. + * @returns {Object} - An object with keys representing the grouped values and arrays as values + */ +export const groupBy = (array, key) => { + return array.reduce((result, item) => { + let groupKey; + + // Handle single key (string), multiple keys (array), or custom function + if (typeof key === 'function') { + groupKey = key(item); + } else if (Array.isArray(key)) { + groupKey = key.map(k => item[k]).join('_'); // Combine multiple keys with underscore + } else { + groupKey = item[key]; + } + + if (!result[groupKey]) { + result[groupKey] = []; + } + result[groupKey].push(item); + return result; + }, {}); +}; + +/** + * Groups purchase request data by M_ItemID + * Terjadi jika ada beberapa item yang sama, maka akan digabungkan berdasarkan M_ItemID dan PoItemUnitID + * @param {Array} purchaseRequestData - Array of purchase request objects + * @returns {Array} - Array of objects with M_ItemID, M_ItemCode, M_ItemDesc, unit information, converted PoQty, and Details array + */ +export const groupPurchaseRequestsByItemId_old = (purchaseRequestData) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']); + console.log("grouped"); + console.log(grouped); + + return Object.keys(grouped).map(itemId => { + const items = grouped[itemId]; + const firstItem = items[0]; + + /* Sebelum Kalkulasi Konversi Item di BE */ + // // Calculate total PoQty from all items + // const totalPoQty = calculateTotalQuantity(items, 'PoQty'); + // // Get the conversion factor from the first item + // const conversionFactor = Number(firstItem.DefaultPurchase.UnitConvertAmount) || 1; + // // Convert the total quantity and round up if it's a decimal + // const convertedPoQty = Math.ceil(convertUnits(totalPoQty, conversionFactor)); + + /* Sesudah Kalkulasi Konversi Item di BE getItem() */ + const convertedPoQty = calculateTotalQuantity(items, 'PoQty') + console.log("Total PoQty for itemId", itemId, " : ", convertedPoQty); + + let price = 0; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - (Number(firstItem.discount) * (Number(firstItem.DefaultPurchase.SupplierPricePrice) / 100)); + } + if (firstItem.discountType === 'R') { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) - Number(firstItem.discount); + } + + } else { + price = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + } + + // Get the price from the first item + const realPrice = Number(firstItem.DefaultPurchase.SupplierPricePrice) || 0; + + // Calculate the total (PoQty * price) + const total = convertedPoQty * price; + + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + TotalPoQty: convertedPoQty, + Price: price, + RealPrice: realPrice, + PriceAfterDiscount: price, + Total: total, + Details: items + }; + }); +}; + +export const groupPurchaseRequestsByItemId_131025 = async (purchaseRequestData, context) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']); + console.log("grouped", grouped); + + const results = await Promise.all(Object.keys(grouped).map(async (itemId) => { + const items = grouped[itemId]; + const firstItem = items[0]; + + const convertedPoQty = calculateTotalQuantity(items, 'PoQty'); + // console.log("Total PoQty for itemId", itemId, ":", convertedPoQty); + + // Fetch the default supplier price based on the first item's M_ItemID and the converted quantity + // penambahan multi harga di PO (untuk mendapatkan harga sesuai qty) + const supplierPrice = await context.dispatch('getDefaultSupplierPrice', { + itemID: firstItem.M_ItemID, + qty: convertedPoQty + }); + + if (supplierPrice == null) { + let snackbar = { + state: true, + type: "warning", + message: `Jumlah Quantity tidak tersedia di rentang harga supplier untuk item ${firstItem.M_ItemDesc}!`, + }; + context.commit("update_snackbar", snackbar); + context.commit("update_supplierPriceSave", supplierPrice); + context.commit("update_itemDesc", firstItem.M_ItemDesc); + } else { + context.commit("update_supplierPriceSave", supplierPrice); + context.commit("update_itemDesc", ''); + } + + let price = 0; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + price = Number(supplierPrice?.SupplierPricePrice || 0) - (Number(firstItem.discount) * (Number(supplierPrice?.SupplierPricePrice || 0) / 100)); + } else if (firstItem.discountType === 'R') { + price = Number(supplierPrice?.SupplierPricePrice || 0) - Number(firstItem.discount); + } + } else { + price = Number(supplierPrice?.SupplierPricePrice || 0) || 0; + } + + const total = convertedPoQty * price; + + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + TotalPoQty: convertedPoQty, + Price: price, + RealPrice: Number(supplierPrice?.SupplierPricePrice || 0), + PriceAfterDiscount: price, + Total: total, + Details: items + }; + })); + + return results; // hasil sudah dalam bentuk array berisi semua item lengkap +}; + +export const groupPurchaseRequestsByItemId = async (purchaseRequestData, context, supplierPriceMap) => { + const grouped = groupBy(purchaseRequestData, ['M_ItemID', 'PoItemUnitID']); + console.log("grouped", grouped); + + const results = Object.keys(grouped).map((itemId) => { + const items = grouped[itemId]; + const firstItem = items[0]; + + const convertedPoQty = calculateTotalQuantity(items, 'PoQty'); + + // Gunakan price dari Map yang sudah di-fetch sebelumnya + const itemParts = itemId.split('_'); + const M_ItemID = itemParts[0]; + const supplierPrice = supplierPriceMap.get(M_ItemID); + + // Validasi supplier price + if (supplierPrice == null) { + let snackbar = { + state: true, + type: "warning", + message: `Jumlah Quantity tidak tersedia di rentang harga supplier untuk item ${firstItem.M_ItemDesc}!`, + }; + context.commit("update_snackbar", snackbar); + context.commit("update_supplierPriceSave", supplierPrice); + context.commit("update_itemDesc", firstItem.M_ItemDesc); + } else { + context.commit("update_supplierPriceSave", supplierPrice); + context.commit("update_itemDesc", ''); + } + + let price = 0; + + if (parseFloat(firstItem.discount) > 0) { + if (firstItem.discountType === 'P') { + price = Number(supplierPrice?.SupplierPricePrice || 0) - (Number(firstItem.discount) * (Number(supplierPrice?.SupplierPricePrice || 0) / 100)); + } else if (firstItem.discountType === 'R') { + price = Number(supplierPrice?.SupplierPricePrice || 0) - Number(firstItem.discount); + } + } else { + price = Number(supplierPrice?.SupplierPricePrice || 0) || 0; + } + + const total = convertedPoQty * price; + + return { + keyID: itemId, + M_ItemID: M_ItemID, + PurchaseOrderID: firstItem.PurchaseOrderID ?? 0, + PurchaseOrderSummaryID: firstItem.PurchaseOrderSummaryID ?? 0, + M_ItemCode: firstItem.M_ItemCode, + M_ItemDesc: firstItem.M_ItemDesc, + discount: firstItem.discount, + discountType: firstItem.discountType, + PoItemUnitID: firstItem.DefaultPurchase.ItemUnitID, + ItemUnitCode: firstItem.DefaultPurchase.ItemUnitCode, + PoItemUnitName: firstItem.DefaultPurchase.ItemUnitName, + TotalPoQty: convertedPoQty, + Price: price, + RealPrice: Number(supplierPrice?.SupplierPricePrice || 0), + PriceAfterDiscount: price, + Total: total, + Details: items + }; + }); + + return results; +}; + +/** + * Formats a number as currency (IDR) + * @param {Number} amount - The amount to format + * @returns {String} - Formatted currency string + */ +export const formatCurrency = (amount) => { + return new Intl.NumberFormat('id-ID', { + style: 'currency', + currency: 'IDR', + minimumFractionDigits: 0 + }).format(amount); +}; + +/** + * Formats a date to a localized string + * @param {Date|String} date - The date to format + * @param {Object} options - Intl.DateTimeFormat options + * @returns {String} - Formatted date string + */ +export const formatDate = (date, options = { + year: 'numeric', + month: 'long', + day: 'numeric' +}) => { + if (!date) return ''; + const dateObj = typeof date === 'string' ? new Date(date) : date; + return new Intl.DateTimeFormat('id-ID', options).format(dateObj); +}; + +/** + * Calculates the total value of purchase requests + * @param {Array} items - Array of purchase request items + * @returns {Number} - Total value + */ +export const calculateTotal = (items) => { + return items.reduce((sum, item) => sum + (Number(item.Total) || 0), 0); +}; + +/** + * Calculates the total quantity of items + * @param {Array} items - Array of purchase request items + * @param {String} qtyField - The field name containing quantity (e.g., 'PoQty') + * @returns {Number} - Total quantity + */ +export const calculateTotalQuantity = (items, qtyField = 'PoQty') => { + console.log("Items in calculateTotalQuantity:", items); + return items.reduce((sum, item) => sum + (Number(item[qtyField]) || 0), 0); +}; + +/** + * Converts units based on the conversion factor + * @param {Number} quantity - The quantity to convert + * @param {Number} conversionFactor - The conversion factor + * @returns {Number} - Converted quantity + */ +export const convertUnits = (quantity, conversionFactor) => { + return quantity / conversionFactor; +}; + +/** + * Filters purchase requests by branch + * @param {Array} items - Array of purchase request items + * @param {String|Array} branchCodes - Branch code(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByBranch = (items, branchCodes) => { + if (!branchCodes) return items; + + const codes = Array.isArray(branchCodes) ? branchCodes : [branchCodes]; + return items.filter(item => codes.includes(item.BranchCode)); +}; + +/** + * Filters purchase requests by regional + * @param {Array} items - Array of purchase request items + * @param {String|Array} regionalIds - Regional ID(s) to filter by + * @returns {Array} - Filtered items + */ +export const filterByRegional = (items, regionalIds) => { + if (!regionalIds) return items; + + const ids = Array.isArray(regionalIds) ? regionalIds : [regionalIds]; + return items.filter(item => ids.includes(item.S_RegionalID)); +}; + +/** + * Validates if a purchase request item has all required fields + * @param {Object} item - Purchase request item + * @returns {Boolean} - True if valid, false otherwise + */ +export const validatePurchaseRequestItem = (item) => { + const requiredFields = [ + 'M_ItemID', + 'M_ItemCode', + 'M_ItemDesc', + 'Price', + 'RequestQty' + ]; + + return requiredFields.every(field => item[field] !== undefined && item[field] !== null); +}; + +/** + * Sorts purchase request items by a specified field + * @param {Array} items - Array of purchase request items + * @param {String} field - Field to sort by + * @param {Boolean} ascending - Sort direction (true for ascending, false for descending) + * @returns {Array} - Sorted items + */ +export const sortPurchaseRequests = (items, field = 'M_ItemDesc', ascending = true) => { + return [...items].sort((a, b) => { + const valueA = a[field]; + const valueB = b[field]; + + if (typeof valueA === 'string' && typeof valueB === 'string') { + return ascending + ? valueA.localeCompare(valueB) + : valueB.localeCompare(valueA); + } + + return ascending + ? (valueA - valueB) + : (valueB - valueA); + }); +}; + +/** + * Validates purchase order data before saving + * @param {Object} context - Vuex context object + * @returns {Boolean} - Returns true if validation passes, false otherwise + */ +export const validatePurchaseOrder = (context) => { + if (context.state.loading) { + let snackbar = { + state: true, + type: "warning", + message: 'Loading sedang berlangsung harap menunggu ...', + }; + context.commit("update_snackbar", snackbar); + return false; + } + + let warningMsg = []; + if (context.state.selectedItem.length == 0) { + warningMsg.push('Belum memilih item'); + } + if (!context.state.refNumber || context.state.refNumber.trim() === '') { + warningMsg.push('Nomor Referensi belum diisi'); + } + if (!context.state.selectedWarehouse || !context.state.selectedWarehouse.WarehouseID && context.state.warehouseType !== 'Multiple') { + warningMsg.push('Tipe Gudang Single Harus memilih Gudang'); + } + if (!context.state.selectedSupplier || !context.state.selectedSupplier.SupplierID) { + warningMsg.push('Supplier belum dipilih'); + } + if (context.state.discountType === 'Percentage') { + const discountValue = (context.state.itemTotal.total * context.state.discountAmount) / 100; + if (discountValue > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } else if (context.state.discountType === 'Absolute') { + if (context.state.discountAmount > context.state.itemTotal.total) { + warningMsg.push('Diskon tidak boleh melebihi total'); + } + } + + context.state.summary.forEach(element => { + if (Number(element.discount) < 0) { + warningMsg.push('Diskon ' + element.M_ItemDesc + ' tidak boleh kurang dari 0'); + } + if (element.discountType === 'P') { + if (Number(element.discount) > 100) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi 100'); + } + } + if (element.discountType === 'R') { + if (Number(element.discount) > Number(element.RealPrice)) { + warningMsg.push('Diskon per item ' + element.M_ItemDesc + ' tidak boleh melebihi dari harga'); + } + } + }); + + if (warningMsg.length > 0) { + let snackbar = { + state: true, + type: "warning", + message: warningMsg.join(", "), + }; + context.commit("update_snackbar", snackbar); + return false; + } + + return true; +}; + +/** + * Menghitung total summary untuk purchase order + * @param {Array} summary - Array data summary + * @param {Number} taxPpn - Persentase pajak PPN + * @param {Number} taxPph - Persentase pajak PPH + * @param {String} discountType - Tipe diskon ('Percentage' atau 'Absolute') + * @param {Number} discountAmount - Jumlah diskon + * @returns {Object} - Object summaryTotal + */ +export const calculateSummaryTotal = (summary, taxPpn = 0, taxPph = 0, discountType = 'Percentage', discountAmount = 0) => { + if (!summary || summary.length === 0) { + return { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }; + } + + // Hitung total dari item summary + const total = summary.reduce((acc, item) => acc + (Number(item.Total) || 0), 0); + + // Hitung diskon berdasarkan tipe + let discount = discountAmount; + if (discountType === 'Percentage') { + discount = (discountAmount / 100) * total; + } + + // Hitung pajak + const newTotal = total - discount; + const ppn = (taxPpn / 100) * newTotal; + const pph = (taxPph / 100) * newTotal; + const tax = ppn + pph; + const finalTotal = newTotal + tax; + + // Return object summaryTotal + return { + total: total, + tax: tax, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: finalTotal, + }; +}; + + +/** + * Menghapus item dari summary dan selectedItem berdasarkan itemId atau detailId + * @param {Array} summary - Array data summary + * @param {Array} selectedItem - Array data selectedItem + * @param {String} itemId - ID item yang akan dihapus (opsional) + * @param {String} detailId - ID detail yang akan dihapus (opsional) + * @returns {Object} - Object berisi summary dan selectedItem yang sudah diupdate + */ +export const deleteItemFromSummary = (summary, selectedItem, itemId = null, detailId = null) => { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = summary.filter(item => item.M_ItemID !== itemId); + const newSelectedItem = selectedItem.filter(item => item.M_ItemID !== itemId); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = selectedItem.filter(item => item.PurchaseRequestFlagID !== detailId); + + // Regenerate summary dari selectedItem yang baru + const newSummary = groupPurchaseRequestsByItemId(newSelectedItem); + + return { + summary: newSummary, + selectedItem: newSelectedItem + }; + } + + return { + summary, + selectedItem + }; +}; \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-v2/index.php b/test/vuex/acc-one-purchase-order-v2/index.php new file mode 100644 index 0000000..d3024d3 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-order-v2/modules/po.js b/test/vuex/acc-one-purchase-order-v2/modules/po.js new file mode 100644 index 0000000..f06746a --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/modules/po.js @@ -0,0 +1,1514 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/po.js"; +import { validatePurchaseOrder, groupPurchaseRequestsByItemId, calculateSummaryTotal } from "../functions/functions.js"; + +export default { + namespaced: true, + state: { + statusOptions: [ + { value: 'All', title: "All" }, + { value: 'Draft', title: "Draft" }, + { value: 'Pending', title: "Pending" }, + { value: 'Approved', title: "Approved" }, + { value: 'Rejected', title: "Rejected" }, + { value: 'Completed', title: "Completed" }, + ], + selectedStatus: { value: 'All', title: "All" }, + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + search: '', + totalPage: 0, + selectedPage: 1, + loading: false, + poList: [ + { + "poNumber": "PO1234566", + "poDate": "01-01-2025", + "poVendor": "PT ABC 123", + "poTotal": "1000000", + "poStatus": "DRAFT", + } + ], + dialogForm: false, + detailData: [], + selectedPr: {}, + loadingDetail: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + //FORM + selectedDateForm: moment(new Date()).format('YYYY-MM-DD'), + selectedDateEnd: moment(new Date()).format('YYYY-MM-DD'), + selectedSupplier: {}, + refNumber: '', + taxPpn: 0, + taxPph: 0, + paymentTerm: 0, + discountType: 'Percentage', + discountTypeList: ['Percentage', 'Absolute'], + discountAmount: 0, + note: '', + warehouseTypeList: ['Single', 'Multiple'], + warehouseType: 'Single', + warehouseList: [], + selectedWarehouse: {}, + itemList: [], + selectedItemTemp: [], + selectedItem: [], + searchItem: '', + itemTotal: { + total: 0, + ppn: 0, + pph: 0, + tax: 0, + discount: 0, + finalTotal: 0, + }, + defaultWarehouse: {}, + shippingCost: 0, + shippingCostStatus: true,//Sudah di bayar atau belum + //END FORM + supplierList: [], + loadingAutocomplete: false, + searchSupplier: "", + dialogConfirmation: false, + dialogDelete: false, + selectedPO: {}, + dialogItem: false, + currentPageItem: 1, + totalPageItem: 0, + dialogFormAct: 'ADD', + summary: [], + summaryTotal: { + total: 0, + ppn: 0, + pph: 0, + tax: 0, + discount: 0, + finalTotal: 0, + }, + deletedItem: [],//kalau edit item sebelumnya yang dihapus masuk sini agar bisa dipilih lagi , + dialogView: false, + itemCategoryList: [], + selectedItemCategory: {}, + open_print: false, + // isValidMultipleWarehouse: false, // Flag untuk validasi multiple warehouse + isValidMultipleWarehouse: { + status: false, + message: '', + }, + riwayatPoList: [], + selected_riwayatPo: {}, + riwayatPoPage: 0, + dialogRiwayat: false, + currPageRiwayatPo: 1, + supplierPriceSave: null, + itemDesc: '' + }, + mutations: { + update_shippingCost(state, val) { + state.shippingCost = val; + }, + update_shippingCostStatus(state, val) { + state.shippingCostStatus = val; + }, + update_selectedItemCategory(state, val) { + state.selectedItemCategory = val; + }, + update_itemCategoryList(state, val) { + state.itemCategoryList = val; + }, + update_dialogView(state, val) { + state.dialogView = val; + }, + update_deletedItem(state, val) { + state.deletedItem = val; + }, + update_summaryTotal(state, val) { + state.summaryTotal = val; + }, + update_summary(state, val) { + state.summary = val; + }, + update_dialogFormAct(state, val) { + state.dialogFormAct = val; + }, + update_totalPageItem(state, val) { + state.totalPageItem = val; + }, + update_currentPageItem(state, val) { + state.currentPageItem = val; + }, + update_dialogItem(state, val) { + state.dialogItem = val; + }, + update_selectedPO(state, val) { + state.selectedPO = val; + }, + update_dialogDelete(state, val) { + state.dialogDelete = val; + }, + update_dialogConfirmation(state, val) { + state.dialogConfirmation = val; + }, + update_defaultWarehouse(state, val) { + state.defaultWarehouse = val; + }, + update_itemTotal(state, val) { + state.itemTotal = val; + }, + update_searchItem(state, val) { + state.searchItem = val; + }, + update_selectedItemTemp(state, val) { + state.selectedItemTemp = val; + }, + update_selectedItem(state, val) { + state.selectedItem = val; + }, + update_itemList(state, val) { + state.itemList = val; + }, + update_warehouseList(state, val) { + state.warehouseList = val; + }, + update_supplierList(state, val) { + state.supplierList = val; + }, + update_searchSupplier(state, val) { + state.searchSupplier = val; + }, + update_loadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + update_selectedWarehouse(state, val) { + state.selectedWarehouse = val; + }, + update_warehouseTypeList(state, val) { + state.warehouseTypeList = val; + }, + update_warehouseType(state, val) { + state.warehouseType = val; + // Disable and clear selectedWarehouse when type is Multiple + if (val === 'Multiple') { + state.selectedWarehouse = {}; + } + }, + update_note(state, val) { + state.note = val; + }, + update_discountAmount(state, val) { + // debugger; + if (state.discountType === 'Percentage' && val > 100) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Diskon tidak boleh lebih dari 100', + }; + state.discountAmount = 100; + return; + } + if (state.discountType === 'Absolute' && val > state.itemTotal.total && state.itemTotal.total > 0) { + state.snackbar = { + state: true, + type: 'warning', + message: 'Diskon tidak boleh lebih dari total', + }; + state.discountAmount = state.itemTotal.total; + return; + } + state.discountAmount = val; + }, + update_discountType(state, val) { + state.discountType = val; + }, + update_paymentTerm(state, val) { + state.paymentTerm = val; + }, + update_taxPpn(state, val) { + if (val > 0) { + state.taxPpn = val; + } else { + state.taxPpn = 0; + } + }, + update_taxPph(state, val) { + if (val > 0) { + state.taxPph = val; + } else { + state.taxPph = 0; + } + }, + update_refNumber(state, val) { + state.refNumber = val; + }, + update_selectedSupplier(state, val) { + state.selectedSupplier = val; + state.currPageRiwayatPo = 1 + }, + update_selectedDateForm(state, val) { + state.selectedDateForm = val; + }, + update_selectedDateEnd(state, val) { + state.selectedDateEnd = val; + }, + update_snackbar(state, val) { + state.snackbar = val; + }, + update_loadingDetail(state, val) { + state.loadingDetail = val; + }, + update_selectedPr(state, val) { + state.selectedPr = val; + }, + update_detailData(state, val) { + state.detailData = val; + }, + update_dialogForm(state, val) { + state.dialogForm = val; + }, + update_selectedStatus(state, val) { + state.selectedStatus = val; + }, + update_selectedDate(state, val) { + state.selectedDate = val; + }, + update_search(state, val) { + state.search = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_totalPage(state, val) { + state.totalPage = val; + }, + update_selectedPage(state, val) { + state.selectedPage = val; + }, + update_poList(state, val) { + state.poList = val; + }, + update_open_print(state, value) { + state.open_print = value + }, + update_isValidMultipleWarehouse(state, value) { + state.isValidMultipleWarehouse = value; + }, + update_riwayatPoList(state, val) { + state.riwayatPoList = val; + }, + update_selected_riwayatPo(state, val) { + state.selected_riwayatPo = val; + }, + update_riwayatPoPage(state, val) { + state.riwayatPoPage = val; + }, + update_dialogRiwayat(state, val) { + state.dialogRiwayat = val; + }, + update_currPageRiwayatPo(state, val) { + state.currPageRiwayatPo = val; + }, + update_supplierPriceSave(state, val) { + state.supplierPriceSave = val; + }, + update_itemDesc(state, val) { + state.itemDesc = val; + }, + }, + actions: { + async deleteItemFromSummary(context, { itemId = null, detailId = null }) { + // Jika itemId ada, hapus seluruh item dan detailsnya + if (itemId) { + const newSummary = context.state.summary.filter(item => item.keyID !== itemId); + const newSelectedItem = context.state.selectedItem.filter(item => item.keyID !== itemId); + if (context.state.dialogFormAct === 'EDIT') { + let deletedItemBefore = JSON.parse(JSON.stringify(context.state.deletedItem)) + const deletedItem = context.state.selectedItem.filter(item => item.keyID === itemId + && item.PurchaseOrderDetailID !== undefined + && item.PurchaseOrderDetailID !== null + && item.PurchaseOrderDetailID !== 0); + let newDeletedItem = [] + deletedItem.forEach(de => { + let cek = deletedItemBefore.find((element) => + element.M_ItemID === de.M_ItemID + && element.PurchaseRequestFlagID === de.PurchaseRequestFlagID + && element.PurchaseOrderDetailID === de.PurchaseOrderDetailID) + if (!cek) { + newDeletedItem.push(de) + } + }); + context.commit('update_deletedItem', [...deletedItemBefore, ...newDeletedItem]); + } + + // const newRef = newSelectedItem.map(obj => obj.PurchaseRequestNumber).join(", "); + const newRef = [...new Set(newSelectedItem.map(obj => obj.PurchaseRequestNumber))].join(", "); + + context.commit("update_refNumber", newRef); + context.commit('update_summary', newSummary); + context.commit('update_selectedItem', newSelectedItem); + } + + // Jika detailId ada, hapus detail spesifik + if (detailId) { + // Hapus dari selectedItem + const newSelectedItem = context.state.selectedItem.filter( + item => item.PurchaseRequestFlagID !== detailId + ); + if (context.state.dialogFormAct === 'EDIT') { + let deletedItemBefore = JSON.parse(JSON.stringify(context.state.deletedItem)) + const deletedItem = context.state.selectedItem.filter( + item => item.PurchaseRequestFlagID === detailId + && item.PurchaseOrderDetailID !== undefined + && item.PurchaseOrderDetailID !== null + && item.PurchaseOrderDetailID !== 0 + ); + let newDeletedItem = [] + deletedItem.forEach(de => { + let cek = deletedItemBefore.find((element) => + element.M_ItemID === de.M_ItemID + && element.PurchaseRequestFlagID === de.PurchaseRequestFlagID + && element.PurchaseOrderDetailID === de.PurchaseOrderDetailID) + if (!cek) { + newDeletedItem.push(de) + } + }); + context.commit('update_deletedItem', [...deletedItemBefore, ...newDeletedItem]); + } + + // Regenerate summary dari selectedItem yang baru + const newSummary = await groupPurchaseRequestsByItemId(newSelectedItem, context); + // const newRef = newSelectedItem.map(obj => obj.PurchaseRequestNumber).join(", "); + const newRef = [...new Set(newSelectedItem.map(obj => obj.PurchaseRequestNumber))].join(", "); + + context.commit("update_refNumber", newRef); + context.commit('update_summary', newSummary); + context.commit('update_selectedItem', newSelectedItem); + } + + // Hitung ulang total + context.dispatch('countItemTotal'); + context.dispatch('generateSummary'); + }, + + generateSummaryTotal(context) { + const summaryTotal = calculateSummaryTotal( + context.state.summary, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + context.commit('update_summaryTotal', summaryTotal); + }, + + async generateSummary_131025(context) { + let data = JSON.parse(JSON.stringify(context.state.selectedItem)); + console.log("Data untuk param groupPurchaseRequestsByItemId:", JSON.parse(JSON.stringify(data))); + + /** + * Tambah validasi: + * > Apakah bisa multiple warehouse? + */ + context.dispatch('isValidMultipleWarehouse'); + + if (context.state.warehouseType === "Multiple") { + data.forEach((element) => { + element.warehouse = { + WarehouseID: element.WarehouseID, + WarehouseName: element.WarehouseName, + }; + }); + } else if (context.state.warehouseType === "Single") { + data.forEach((element) => { + element.warehouse = context.state.selectedWarehouse; // Semua item pakai warehouse yang sama + }); + } + + let summary = await groupPurchaseRequestsByItemId(data, context); + context.commit('update_summary', summary); + console.log("Summary setelah grouping:", JSON.parse(JSON.stringify(summary))); + + // Hitung summary total menggunakan fungsi dari functions.js + const summaryTotal = calculateSummaryTotal( + summary, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + }, + + async generateSummary(context) { + let data = JSON.parse(JSON.stringify(context.state.selectedItem)); + console.log("Data untuk param groupPurchaseRequestsByItemId:", JSON.parse(JSON.stringify(data))); + + // Validasi multiple warehouse + context.dispatch('isValidMultipleWarehouse'); + + if (context.state.warehouseType === "Multiple") { + data.forEach((element) => { + element.warehouse = { + WarehouseID: element.WarehouseID, + WarehouseName: element.WarehouseName, + }; + }); + } else if (context.state.warehouseType === "Single") { + data.forEach((element) => { + element.warehouse = context.state.selectedWarehouse; + }); + } + + // **Batch fetch supplier prices sekali saja** + const supplierPriceMap = await context.dispatch('batchGetSupplierPrices', data); + + // Pass priceMap ke fungsi grouping + let summary = await groupPurchaseRequestsByItemId(data, context, supplierPriceMap); + context.commit('update_summary', summary); + console.log("Summary setelah grouping:", JSON.parse(JSON.stringify(summary))); + + const summaryTotal = calculateSummaryTotal( + summary, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + }, + + // Di Vuex store actions + async batchGetSupplierPrices(context, items) { + // Group items by M_ItemID dan sum qty + const itemQtyMap = items.reduce((acc, item) => { + const itemId = item.M_ItemID; + const qty = Number(item.PoQty || 0); + + if (!acc[itemId]) { + acc[itemId] = qty; + } else { + acc[itemId] += qty; + } + + return acc; + }, {}); + + // Fetch all prices in parallel + const pricePromises = Object.entries(itemQtyMap).map(async ([itemId, qty]) => { + const supplierPrice = await context.dispatch('getDefaultSupplierPrice', { + itemID: itemId, + qty: qty + }); + + return { itemId, qty, supplierPrice }; + }); + + const results = await Promise.all(pricePromises); + + // Convert to Map for easy lookup + const priceMap = new Map( + results.map(r => [r.itemId, r.supplierPrice]) + ); + + return priceMap; + }, + + multipleWarehouseValidation(context, selectedItem) { + let data; + + if (!selectedItem || selectedItem.length === 0) { + data = JSON.parse(JSON.stringify(context.state.selectedItem)); + } else { + data = JSON.parse(JSON.stringify(selectedItem)); + } + + // Pakai 'Set' JS Object yang hanya menyimpan nilai unik. + const warehouseIds = new Set(); + + data.forEach(item => { + if (item.WarehouseID) { + // Kalau ada yang sama maka disimpan sekali. + warehouseIds.add(item.WarehouseID); + } + }); + + if (warehouseIds.size > 1) { + return true; // Ada lebih dari satu WarehouseID + } else { + return false; // Hanya ada satu WarehouseID + } + }, + + async isValidMultipleWarehouse(context) { + /** + * @param: array of PurchaseRequestDetailID dari selectedItem + * @api: api.isValidMultipleWarehouse + * @return: JSON -> {data.status (boolean), data.message (string)} + * + */ + if (context.state.selectedItem.length === 0) { + return false; // Tidak ada item yang dipilih + } + try { + let payload = { + "PurchaseRequestDetailIDs": context.state.selectedItem.map(item => item.PurchaseRequestDetailID), + "token": one_token(), + }; + + let response = await api.isValidMultipleWarehouse(payload) + + console.log("Payload untuk isValidMultipleWarehouse:", JSON.parse(JSON.stringify(payload.PurchaseRequestDetailIDs))); + console.log("Response dari isValidMultipleWarehouse:", JSON.parse(JSON.stringify(response))); + + if (response.status !== "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_isValidMultipleWarehouse", { + status: false, + message: '', + }); + context.commit("update_snackbar", snackbar); + } else {; + context.commit("update_isValidMultipleWarehouse", { + status: response.data.status, + message: response.data.message, + }); + if(response.data.status == false) { + context.commit("update_warehouseType", 'Single'); + context.commit("update_selectedWarehouse", context.state.selectedWarehouse); + } + }; + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + } + }, + + assignEdit(context) { + let data = context.state.selectedPO + context.commit("update_selectedDateForm", data.PurchaseOrderDate); + context.commit("update_searchSupplier", data.SupplierName); + context.commit("update_selectedSupplier", { + "SupplierID": data.PurchaseOrderSupplierID, + "SupplierCode": data.SupplierCode, + "SupplierName": data.SupplierName + }); + context.commit("update_selectedItemCategory", { + "itemCategoryID": data.itemCategoryID, + "itemCategoryName": data.itemCategoryName + }); + context.commit("update_refNumber", data.PurchaseOrderRefNumber); + context.commit("update_shippingCost", data.PurchaseOrderShippingCost); + context.commit("update_shippingCostStatus", data.PurchaseOrderShippingCostStatus === 'Y' ? true : false); + context.commit("update_taxPpn", data.PurchaseOrderTaxPercentPpn); + context.commit("update_taxPph", data.PurchaseOrderTaxPercentPph); + context.commit("update_paymentTerm", data.PurchaseOrderPaymentTerm); + context.commit("update_discountType", data.PurchaseOrderDiscountPercent > 0 ? 'Percentage' : 'Absolute'); + if (data.PurchaseOrderDiscountPercent > 0) { + context.commit("update_discountAmount", parseFloat(data.PurchaseOrderDiscountPercent)); + } else { + context.commit("update_discountAmount", parseFloat(data.PurchaseOrderDiscountAmount)); + } + context.commit("update_note", data.PurchaseOrderNote); + context.commit("update_warehouseType", data.PurchaseOrderWarehouseType); + context.commit("update_selectedWarehouse", { + "WarehouseID": data.PurchaseOrderWarehouseID, + "WarehouseCode": data.WarehouseCode, + "WarehouseName": data.WarehouseName, + }); + context.commit("update_dialogFormAct", 'EDIT'); + context.dispatch("countItemTotal"); + }, + + async resetForm(context) { + context.commit("update_selectedDateForm", moment(new Date()).format('YYYY-MM-DD')); + context.commit("update_selectedSupplier", {}); + context.commit("update_selectedWarehouse", {}); + context.commit("update_defaultWarehouse", {}); + context.commit("update_warehouseType", 'Single'); + context.commit("update_refNumber", ''); + context.commit("update_taxPpn", 0); + context.commit("update_taxPph", 0); + context.commit("update_paymentTerm", 0); + context.commit("update_discountType", 'Percentage'); + context.commit("update_discountAmount", 0); + context.commit("update_note", ''); + + context.commit("update_selectedItemTemp", []); + context.commit("update_selectedItem", []); + context.commit("update_deletedItem", []); + context.commit("update_selectedItemCategory", {}); + context.commit("update_summary", []); + + context.commit("update_shippingCost", 0); + context.commit("update_shippingCostStatus", true); + + context.commit("update_itemList", []); + context.commit("update_searchItem", ''); + + context.commit("update_warehouseList", []); + context.commit("update_searchSupplier", 'null'); + context.commit("update_supplierList", []); + context.commit("update_dialogFormAct", 'ADD'); + context.commit("update_summaryTotal", { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }); + context.commit("update_itemTotal", { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + }); + }, + + countItemTotal(context) { + let selectedItem = context.state.selectedItem; + if (selectedItem.length === 0) { + let hasil = { + total: 0, + tax: 0, + ppn: 0, + pph: 0, + discount: 0, + finalTotal: 0, + } + context.commit("update_itemTotal", hasil); + return; + } + + // Fix: Ensure we're working with numeric values + let total = selectedItem.reduce((acc, item) => { + // Convert string to number if needed + const itemTotal = typeof item.Total === 'string' ? + parseFloat(item.Total.replace(/\./g, '').replace(',', '.')) : + item.Total; + return acc + (isNaN(itemTotal) ? 0 : itemTotal); + }, 0); + + total = Math.round(total * 100) / 100; + + let discount = parseFloat(context.state.discountAmount) || 0; + if (context.state.discountType === 'Percentage') { + discount = Math.round((discount / 100) * total * 100) / 100; + } + + let newTotal = Math.round((total - discount) * 100) / 100; + let ppn = Math.round((parseFloat(context.state.taxPpn) / 100) * newTotal * 100) / 100; + let pph = Math.round((parseFloat(context.state.taxPph) / 100) * newTotal * 100) / 100; + let pajak = Math.round((ppn + pph) * 100) / 100; + let final = Math.round((newTotal + pajak) * 100) / 100; + + let hasil = { + total: total, + tax: pajak, + ppn: ppn, + pph: pph, + discount: discount, + finalTotal: final, + } + context.commit("update_itemTotal", hasil); + }, + + updatePoQty(context, { itemId, newPoQty }) { + let updatedSelectedItem = context.state.selectedItem.map(item => { + if (item.PurchaseRequestFlagID === itemId) { + // Convert string to number and ensure minimum value of 1 + const numericPoQty = Number(newPoQty); + item.PoQty = Math.max(1, Math.floor(isNaN(numericPoQty) ? 1 : numericPoQty)); + + // Recalculate item total + let price = item.DefaultPurchase?.SupplierPricePrice || 0; + + // Apply discount if exists + if (item.discount > 0) { + if (item.discountType === 'P') { + price = price - (item.discount * price / 100); + } else if (item.discountType === 'R') { + price = price - item.discount; + } + } + + item.Total = item.PoQty * price; + } + return item; + }); + + context.commit('update_selectedItem', updatedSelectedItem); + + // Regenerate summary + context.dispatch('generateSummary'); + context.dispatch('countItemTotal'); + context.dispatch('generateSummaryTotal'); + }, + + async getSupplier(context) { + if (context.state.searchSupplier.length < 2) return; + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + token: one_token(), + search: context.state.searchSupplier, + + }; + + let response = await api.getSupplier(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_supplierList", data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getItemCategory(context) { + + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + token: one_token(), + + }; + + let response = await api.getItemCategory(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_itemCategoryList", data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getWarehouse(context) { + + context.commit("update_loadingAutocomplete", true); + + try { + var payload = { + regionalId: one_user().S_RegionalID, + categoryID: context.state.selectedItemCategory.itemCategoryID, + token: one_token(), + }; + + let response = await api.getWarehouse(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + response.data.records.forEach(element => { + if (element.WarehouseIsDefault === 'Y') { + context.commit("update_defaultWarehouse", element); + context.commit("update_selectedWarehouse", element); + } + + }); + context.commit("update_warehouseList", response.data.records); + context.commit("update_loadingAutocomplete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingAutocomplete", false); + } + }, + + async getItem(context) { + context.commit("update_loading", true); + try { + var payload = { + "search": context.state.searchItem, + "currentPage": context.state.currentPageItem, + "supplierID": context.state.selectedSupplier.SupplierID, + "itemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "regionalId": one_user().S_RegionalID, + "token": one_token(), + }; + + let response = await api.getItem(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_itemList", data.records); + context.commit("update_totalPageItem", data.total); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getItemUpdate(context) { + context.commit("update_loading", true); + try { + var payload = { + "POID": context.state.selectedPO.PurchaseOrderID, + "token": one_token(), + }; + + let response = await api.getItemUpdate(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.totalPage, + }; + + context.commit("update_selectedItem", data.records); + /** + * Tambah validasi: + * > Apakah bisa multiple warehouse? + */ + context.dispatch('isValidMultipleWarehouse'); + + context.commit("update_summary", response.data.summary) + context.dispatch("countItemTotal"); + // Hitung summary total menggunakan fungsi dari functions.js + // TODO: Check ini akibat penyesuaian + const summaryTotal = calculateSummaryTotal( + response.data.summary, + context.state.taxPpn, + context.state.taxPph, + context.state.discountType, + context.state.discountAmount + ); + + context.commit('update_summaryTotal', summaryTotal); + + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async saveOrder(context) { + try { + if (!validatePurchaseOrder(context)) { + return; + } + + const invalidQtyItems = context.state.selectedItem.filter(item => { + // Convert string to number first + const poQty = Number(item.PoQty); + + // Check if conversion failed (NaN), is less than 1, or not an integer + return isNaN(poQty) || poQty < 1 || !Number.isInteger(poQty); + }); + + if (invalidQtyItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki quantity minimal 1", + } + context.commit("update_snackbar", snackbar); + return; + } + + // Validasi: Cek apakah ada item dengan harga supplier null + if (context.state.supplierPriceSave === null) { + let snackbar = { + state: true, + type: "error", + message: `Jumlah Quantity tidak tersedia di rentang harga supplier pada item ${context.state.itemDesc}!`, + } + context.commit("update_snackbar", snackbar); + return; + } + + context.commit("update_loading", true); + + var payload = { + "token": one_token(), + "Date": context.state.selectedDateForm, + "RefNumber": context.state.refNumber, + "SupplierID": context.state.selectedSupplier.SupplierID, + "ItemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "TaxPercent": context.state.taxPpn, + "PaymentTerm": context.state.paymentTerm, + "DiscountPercent": context.state.discountType === 'Percentage' ? context.state.discountAmount : 0, + "DiscountAmount": context.state.discountType === 'Absolute' ? context.state.discountAmount : 0, + "WarehouseType": context.state.warehouseType, + "WarehouseID": context.state.selectedWarehouse.WarehouseID, + "Note": context.state.note, + "SubTotal": context.state.summaryTotal.total, + "TaxPercentPph": context.state.taxPph, + "TaxPercentPpn": context.state.taxPpn, + "TaxAmount": context.state.summaryTotal.tax, + "TaxAmountPph": context.state.summaryTotal.pph, + "TaxAmountPpn": context.state.summaryTotal.ppn, + "GrandTotal": context.state.summaryTotal.finalTotal, + "ShippingCost": context.state.shippingCost, + "ShippingCostStatus": context.state.shippingCostStatus, + // "Details": detail, + "Summary": context.state.summary + }; + + // Validasi Total Tidak Boleh <0 + const financialChecks = [ + { value: payload.GrandTotal, name: "Total" }, + { value: payload.SubTotal, name: "Sub Total" }, + { value: payload.TaxAmount, name: "Pajak" }, + { value: payload.TaxAmountPph, name: "Pajak PPH" }, + { value: payload.TaxAmountPpn, name: "Pajak PPN" }, + { value: payload.DiscountAmount, name: "Diskon" }, + { value: payload.ShippingCost, name: "Biaya Ekspedisi" } + ]; + + for (const check of financialChecks) { + if (check.value < 0) { + let snackbar = { + state: true, + type: "error", + message: `${check.name} tidak boleh kurang dari 0`, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + return; + } + } + + let response = await api.saveOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil simpan data", + } + context.commit("update_snackbar", snackbar); + + + context.commit("update_loading", false); + context.commit("update_dialogForm", false); + context.dispatch("resetForm"); + context.dispatch("searchData"); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async searchData(context) { + context.commit("update_loading", true); + try { + var url_string = window.location.href + var url = new URL(url_string); + var xdate = url.searchParams.get("date"); + var xsearch = url.searchParams.get("search"); + + if (xsearch) { + context.commit("update_search", xsearch); + } + if (xdate) { + context.commit("update_selectedDate", xdate); + context.commit("update_selectedDateEnd", xdate); + } + + var payload = { + "token": one_token(), + "currentPage": context.state.selectedPage, + "search": context.state.search, + "startDate": context.state.selectedDate, + "endDate": context.state.selectedDateEnd, + "status": context.state.selectedStatus.value, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("update_totalPage", response.data.totalPage); + context.commit("update_poList", data.records); + context.commit("update_loading", false); + context.dispatch("system/getlistnotif", null, { root: true }) + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async requestOrder(context) { + context.commit("update_loading", true); + + try { + + var payload = { + "token": one_token(), + "ID": context.state.selectedPO.PurchaseOrderID, + }; + + let response = await api.requestOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil request order", + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + context.commit("update_dialogConfirmation", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async deleteOrder(context) { + context.commit("update_loading", true); + + try { + var payload = { + "token": one_token(), + "PurchaseOrderId": context.state.selectedPO.PurchaseOrderID, + }; + + let response = await api.deleteOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil hapus order", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + context.commit("update_dialogDelete", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async updateOrder(context) { + try { + if (!validatePurchaseOrder(context)) { + return; + } + + const invalidQtyItems = context.state.selectedItem.filter(item => { + // Convert string to number first + const poQty = Number(item.PoQty); + + // Check if conversion failed (NaN), is less than 1, or not an integer + return isNaN(poQty) || poQty < 1 || !Number.isInteger(poQty); + }); + + console.log("InvalidQtyItem updateOrder", invalidQtyItems) + + if (invalidQtyItems.length > 0) { + let snackbar = { + state: true, + type: "error", + message: "Semua item harus memiliki quantity minimal 1", + } + context.commit("update_snackbar", snackbar); + return; + } + + // Validasi: Cek apakah ada item dengan harga supplier null + if (context.state.supplierPriceSave === null) { + let snackbar = { + state: true, + type: "error", + message: `Jumlah Quantity tidak tersedia di rentang harga supplier pada item ${context.state.itemDesc}!`, + } + context.commit("update_snackbar", snackbar); + return; + } + + var payload = { + "token": one_token(), + "Date": context.state.selectedDateForm, + "RefNumber": context.state.refNumber, + "SupplierID": context.state.selectedSupplier.SupplierID, + "TaxPercent": context.state.taxPpn, + "PaymentTerm": context.state.paymentTerm, + "ItemCategoryID": context.state.selectedItemCategory.itemCategoryID, + "DiscountPercent": context.state.discountType === 'Percentage' ? context.state.discountAmount : 0, + "DiscountAmount": context.state.discountType === 'Absolute' ? context.state.discountAmount : 0, + "WarehouseType": context.state.warehouseType, + "WarehouseID": context.state.selectedWarehouse.WarehouseID, + "Note": context.state.note, + "SubTotal": context.state.summaryTotal.total, + "TaxPercentPph": context.state.taxPph, + "TaxPercentPpn": context.state.taxPpn, + "TaxAmount": context.state.summaryTotal.tax, + "TaxAmountPph": context.state.summaryTotal.pph, + "TaxAmountPpn": context.state.summaryTotal.ppn, + "GrandTotal": context.state.summaryTotal.finalTotal, + "ShippingCost": context.state.shippingCost, + "ShippingCostStatus": context.state.shippingCostStatus, + "PO": context.state.selectedPO, + "Summary": context.state.summary, + "deletedItem": context.state.deletedItem + }; + + // Validasi Total Tidak Boleh <0 + const financialChecks = [ + { value: payload.GrandTotal, name: "Total" }, + { value: payload.SubTotal, name: "Sub Total" }, + { value: payload.TaxAmount, name: "Pajak" }, + { value: payload.TaxAmountPph, name: "Pajak PPH" }, + { value: payload.TaxAmountPpn, name: "Pajak PPN" }, + { value: payload.DiscountAmount, name: "Diskon" }, + { value: payload.ShippingCost, name: "Biaya Ekspedisi" } + ]; + + for (const check of financialChecks) { + if (check.value < 0) { + let snackbar = { + state: true, + type: "error", + message: `${check.name} tidak boleh kurang dari 0`, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + return; + } + } + + context.commit("update_loading", true); + let response = await api.updateOrder(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + let snackbar = { + state: true, + type: "success", + message: "Berhasil simpan data", + } + context.commit("update_snackbar", snackbar); + + + context.commit("update_loading", false); + context.commit("update_dialogForm", false); + context.dispatch("resetForm"); + context.dispatch("searchData"); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async approveOrder(context, payload) { + context.commit("update_loading", true); + try { + payload.token = one_token() + + let response = await api.approvePOrder(payload); + if (response.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let params = { token: one_token(), id: payload.poID } + let generateitempo = await api.generateItemPO(params) + if (generateitempo.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let snackbar = { + state: true, + type: "success", + message: "Berhasil approve order", + } + context.commit("update_snackbar", snackbar); + + await context.dispatch("searchData"); + context.commit("update_loading", false); + } + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getPoBySupplier(context) { + context.commit("update_loading", true); + + try { + var payload = { + token: one_token(), + supplierID: context.state.selectedSupplier.SupplierID, + currentPage: context.state.currPageRiwayatPo, + + }; + + let response = await api.getPoBySupplier(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + totalPage: response.data.totalPage, + }; + + + context.commit("update_riwayatPoList", data.records); + context.commit("update_riwayatPoPage", data.totalPage); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + + async getDefaultSupplierPrice(context, payload) { + context.commit("update_loading", true); + try { + payload.token = one_token() + payload.supplierID = context.state.selectedSupplier.SupplierID + + let response = await api.getDefaultSupplierPrice(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + }; + + context.commit("update_loading", false); + + return data.records; + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + }, + }, +}; diff --git a/test/vuex/acc-one-purchase-order-v2/store.js b/test/vuex/acc-one-purchase-order-v2/store.js new file mode 100644 index 0000000..e107174 --- /dev/null +++ b/test/vuex/acc-one-purchase-order-v2/store.js @@ -0,0 +1,14 @@ +// import manager from "./modules/manager.js"; +// import prkacab from "./modules/prkacab.js" +import system from "../../../apps/modules/system/system.js"; +import po from "./modules/po.js"; + +export const store = new Vuex.Store({ + modules: { + po: po, + system: system + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-purchase-request-direct-approved-nota/api/api-manager.js b/test/vuex/acc-one-purchase-request-direct-approved-nota/api/api-manager.js new file mode 100644 index 0000000..d36c578 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved-nota/api/api-manager.js @@ -0,0 +1,154 @@ +const URL = "/one-api/mockup/purchase/manager/"; + +export async function search(payload) { + try { + var response = await axios.post(URL + "PurchaseRequestDirectApprovedNota/search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getlevel(payload) { + try { + var response = await axios.post(URL + "PurchaseRequestDirectApprovedNota/getlevel", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function searchDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirectApprovedNota/searchDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirectApprovedNota/deleteDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approveRequestNota(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirectApprovedNota/approveRequestNota", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function rejectRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirectApprovedNota/rejectRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirectApprovedNota/updateDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} diff --git a/test/vuex/acc-one-purchase-request-direct-approved-nota/components/formDialogAttachtment.vue b/test/vuex/acc-one-purchase-request-direct-approved-nota/components/formDialogAttachtment.vue new file mode 100644 index 0000000..4fdfa7f --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved-nota/components/formDialogAttachtment.vue @@ -0,0 +1,148 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct-approved-nota/components/requestListing.vue b/test/vuex/acc-one-purchase-request-direct-approved-nota/components/requestListing.vue new file mode 100644 index 0000000..23d7b50 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved-nota/components/requestListing.vue @@ -0,0 +1,1100 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-request-direct-approved-nota/index.php b/test/vuex/acc-one-purchase-request-direct-approved-nota/index.php new file mode 100644 index 0000000..2af0937 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved-nota/index.php @@ -0,0 +1,67 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct-approved-nota/modules/manager.js b/test/vuex/acc-one-purchase-request-direct-approved-nota/modules/manager.js new file mode 100644 index 0000000..ebf5ece --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved-nota/modules/manager.js @@ -0,0 +1,412 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api-manager.js"; + +export default { + namespaced: true, + state: { + mainTable: [], + detailTable: [], + countMainTable: 0, + countDetailTable: 0, + mainTableLoadingStatus: 0, + detailTableLoadingStatus: 0, + mainTableErrorMessage: "", + detailTableErrorMessage: "", + mainTableCurrentPage: 1, + mainTableLastId: -1, + + selectedMainTable: {}, + selectedDetailTable: {}, + + statusOptions: [ + { value: 0, title: "All" }, + { value: 2, title: "Pending" }, + { value: 3, title: "Approved" }, + { value: 4, title: "Rejected" }, + { value: 5, title: "Paid" }, + { value: 6, title: "Completed" }, + ], + + menuStartDate: false, + menuEndDate: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + fStatus: 0, + fSearch: "", + + xNote: "", + xAmount: 0, + xPrice: 0, + xPRID: 0, + xPRDID: 0, + xStatus: "", + xDescriptionDetail: "", + + dialogDetail: false, + errMessage: "", + succesMessage: "", + alertError: false, + alertSuccess: false, + errors: [], + levelname: [], + dialog_form: false, + show_progrees_upload: false, + imageFiles: [], + imagePreviews: [], + cekFile: false, + actAttach: "" + }, + mutations: { + updateMainTable(state, val) { + state.mainTable = val; + }, + updateLevelName(state, val) { + state.levelname = val; + }, + updateDetailTable(state, val) { + state.detailTable = val; + }, + updateCountMainTable(state, val) { + state.countMainTable = val; + }, + updateCountDetailTable(state, val) { + state.countDetailTable = val; + }, + updateMainTableLoadingStatus(state, val) { + state.mainTableLoadingStatus = val; + }, + updateDetailTableLoadingStatus(state, val) { + state.detailTableLoadingStatus = val; + }, + updateMainTableErrorMessage(state, val) { + state.mainTableErrorMessage = val; + }, + updateDetailTableErrorMessage(state, val) { + state.detailTableErrorMessage = val; + }, + updateMainTableCurrentPage(state, val) { + state.mainTableCurrentPage = val; + }, + updateMainTableLastId(state, val) { + state.mainTableLastId = val; + }, + + updateSelectedMainTable(state, val) { + state.selectedMainTable = val; + }, + updateSelectedDetailTable(state, val) { + state.selectedDetailTable = val; + }, + + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateFStatus(state, val) { + state.fStatus = val; + }, + updateFSearch(state, val) { + state.fSearch = val; + }, + + updateXNote(state, val) { + state.xNote = val; + }, + updateXAmount(state, val) { + state.xAmount = val; + }, + updatexPrice(state, val) { + state.xPrice = val; + }, + updateXPRID(state, val) { + state.xPRID = val; + }, + updateXPRDID(state, val) { + state.xPRDID = val; + }, + updateXStatus(state, val) { + state.xStatus = val; + }, + updateXDescriptionDetail(state, val) { + state.xDescriptionDetail = val; + }, + + updateDialogDetail(state, val) { + state.dialogDetail = val; + }, + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateSuccessMessage(state, val) { + state.successMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateAlertSuccess(state, val) { + state.alertSuccess = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + update_dialog_form(state, val) { + state.dialog_form = val; + }, + update_show_progrees_upload(state, val) { + state.show_progrees_upload = val + }, + update_imageFiles(state, val) { + state.imageFiles = val + }, + update_imagePreviews(state, val) { + state.imagePreviews = val + }, + update_cekFile(state, val) { + state.cekFile = val + }, + update_actAttach(state, val) { + state.actAttach = val + } + }, + actions: { + async search(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + currentPage: context.state.mainTableCurrentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus, + search: context.state.fSearch, + lastId: -1, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateMainTable", data.records); + context.commit("updateCountMainTable", data.total); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async getlevel(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var payload = { + token: one_token() + }; + + let response = await api.getlevel(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateLevelName", data.records[0].M_ApproveLevelName); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async searchDetail(context) { + context.commit("updateDetailTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + PRID: context.state.selectedMainTable.PurchaseRequestDirectID, + }; + + let response = await api.searchDetail(payload); + if (response.status != "OK") { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", response.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("updateDetailTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateDetailTable", data.records); + context.commit("updateCountDetailTable", data.total); + } + } catch (e) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", e.message); + } + }, + async updateDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateDetail(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request [${payload.PRDDescription}] telah diperbarui`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async rejectRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.rejectRequest(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request [${payload.PRNumber}] sudah ditolak`; + context.commit("updateSuccessMessage", msg); + context.commit("updateSelectedMainTable", {}); + context.commit("updateDetailTable", []); + context.commit("updateSelectedDetailTable", {}); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Request [${payload.PRDDescription}] sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async approveRequestNota(context, payload) { + try { + payload.token = one_token(); + + let response = await api.approveRequestNota(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request nota [${payload.PRNumber}] telah diapprove`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + }, +}; diff --git a/test/vuex/acc-one-purchase-request-direct-approved-nota/store.js b/test/vuex/acc-one-purchase-request-direct-approved-nota/store.js new file mode 100644 index 0000000..dac7742 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved-nota/store.js @@ -0,0 +1,11 @@ +import manager from "./modules/manager.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + manager: manager, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-purchase-request-direct-approved/api/api-manager.js b/test/vuex/acc-one-purchase-request-direct-approved/api/api-manager.js new file mode 100644 index 0000000..547ed87 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/api/api-manager.js @@ -0,0 +1,177 @@ +const URL = "/one-api/mockup/purchase/manager/"; + +export async function search(payload) { + try { + var response = await axios.post(URL + "purchaseRequestDirectApproved/search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getlevel(payload) { + try { + var response = await axios.post(URL + "purchaseRequestDirectApproved/getlevel", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function searchDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequestDirectApproved/searchDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequestDirectApproved/deleteDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approveRequest(payload) { + try { + var response = await axios.post( + URL + "purchaseRequestDirectApproved/approveRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function rejectRequest(payload) { + try { + var response = await axios.post( + URL + "purchaseRequestDirectApproved/rejectRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function unApproveRequest(payload) { + try { + var response = await axios.post( + URL + "purchaseRequestDirectApproved/unApproveRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequestDirectApproved/updateDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} diff --git a/test/vuex/acc-one-purchase-request-direct-approved/components/alertDialog.vue b/test/vuex/acc-one-purchase-request-direct-approved/components/alertDialog.vue new file mode 100644 index 0000000..a550347 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/components/alertDialog.vue @@ -0,0 +1,50 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct-approved/components/formDialogAttachtment.vue b/test/vuex/acc-one-purchase-request-direct-approved/components/formDialogAttachtment.vue new file mode 100644 index 0000000..4fdfa7f --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/components/formDialogAttachtment.vue @@ -0,0 +1,148 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct-approved/components/formEditReques.vue b/test/vuex/acc-one-purchase-request-direct-approved/components/formEditReques.vue new file mode 100644 index 0000000..63b0603 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/components/formEditReques.vue @@ -0,0 +1,116 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct-approved/components/formEditRequest.vue b/test/vuex/acc-one-purchase-request-direct-approved/components/formEditRequest.vue new file mode 100644 index 0000000..6169225 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/components/formEditRequest.vue @@ -0,0 +1,234 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct-approved/components/listingRequest.vue b/test/vuex/acc-one-purchase-request-direct-approved/components/listingRequest.vue new file mode 100644 index 0000000..d153e31 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/components/listingRequest.vue @@ -0,0 +1,748 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct-approved/components/requestListing.vue b/test/vuex/acc-one-purchase-request-direct-approved/components/requestListing.vue new file mode 100644 index 0000000..3273b76 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/components/requestListing.vue @@ -0,0 +1,1301 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-request-direct-approved/index.php b/test/vuex/acc-one-purchase-request-direct-approved/index.php new file mode 100644 index 0000000..50c8b61 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/index.php @@ -0,0 +1,69 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct-approved/modules/manager.js b/test/vuex/acc-one-purchase-request-direct-approved/modules/manager.js new file mode 100644 index 0000000..e0b6348 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/modules/manager.js @@ -0,0 +1,508 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api-manager.js"; + +export default { + namespaced: true, + state: { + mainTable: [], + detailTable: [], + countMainTable: 0, + countDetailTable: 0, + mainTableLoadingStatus: 0, + detailTableLoadingStatus: 0, + mainTableErrorMessage: "", + detailTableErrorMessage: "", + mainTableCurrentPage: 1, + mainTableLastId: -1, + + selectedMainTable: {}, + selectedDetailTable: {}, + + statusOptions: [ + { value: 0, title: "All" }, + { value: 2, title: "Pending" }, + { value: 3, title: "Approved" }, + { value: 4, title: "Rejected" }, + { value: 5, title: "Paid" }, + { value: 6, title: "Completed" }, + ], + + menuStartDate: false, + menuEndDate: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + fStatus: "All", + fSearch: "", + + xNote: "", + xAmount: 0, + xPrice: 0, + xTotal: 0, + xPRID: 0, + xPRDID: 0, + xStatus: "", + xStatusNota: "", + xDescriptionDetail: "", + + dialogDetail: false, + errMessage: "", + succesMessage: "", + alertError: false, + alertSuccess: false, + errors: [], + levelname: [], + dialog_form: false, + show_progrees_upload: false, + imageFiles: [], + imagePreviews: [], + cekFile: false, + actAttach: "", + open_dialog_info: false, + msg_info: "", + status: '', + xstartdate: '', + successMessage:'', + flag: '', + }, + mutations: { + updateMainTable(state, val) { + state.mainTable = val; + }, + updateLevelName(state, val) { + state.levelname = val; + }, + updateDetailTable(state, val) { + state.detailTable = val; + }, + updateCountMainTable(state, val) { + state.countMainTable = val; + }, + updateCountDetailTable(state, val) { + state.countDetailTable = val; + }, + updateMainTableLoadingStatus(state, val) { + state.mainTableLoadingStatus = val; + }, + updateDetailTableLoadingStatus(state, val) { + state.detailTableLoadingStatus = val; + }, + updateMainTableErrorMessage(state, val) { + state.mainTableErrorMessage = val; + }, + updateDetailTableErrorMessage(state, val) { + state.detailTableErrorMessage = val; + }, + updateMainTableCurrentPage(state, val) { + state.mainTableCurrentPage = val; + }, + updateMainTableLastId(state, val) { + state.mainTableLastId = val; + }, + + updateSelectedMainTable(state, val) { + state.selectedMainTable = val; + }, + updateSelectedDetailTable(state, val) { + state.selectedDetailTable = val; + }, + + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateFStatus(state, val) { + state.fStatus = val; + }, + updateFSearch(state, val) { + state.fSearch = val; + }, + updateXNote(state, val) { + state.xNote = val; + }, + updateXAmount(state, val) { + state.xAmount = val; + }, + updatexPrice(state, val) { + state.xPrice = val; + }, + updatexTotal(state, val) { + state.xTotal = val; + }, + updateXPRID(state, val) { + state.xPRID = val; + }, + updateXPRDID(state, val) { + state.xPRDID = val; + }, + updateXStatus(state, val) { + state.xStatus = val; + }, + updateXStatusNota(state, val) { + state.XStatusNota = val; + }, + updateXDescriptionDetail(state, val) { + state.xDescriptionDetail = val; + }, + + updateDialogDetail(state, val) { + state.dialogDetail = val; + }, + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateSuccessMessage(state, val) { + state.successMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateAlertSuccess(state, val) { + state.alertSuccess = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + update_dialog_form(state, val) { + state.dialog_form = val; + }, + update_show_progrees_upload(state, val) { + state.show_progrees_upload = val + }, + update_imageFiles(state, val) { + state.imageFiles = val + }, + update_imagePreviews(state, val) { + state.imagePreviews = val + }, + update_cekFile(state, val) { + state.cekFile = val + }, + update_actAttach(state, val) { + state.actAttach = val + }, + update_open_dialog_info(state, val) { + state.open_dialog_info = val + }, + update_msg_info(state, val) { + state.msg_info = val + }, + update_status(state, val) { + state.status = val + }, + update_xstartdate(state, val) { + state.xstartdate = val + }, + update_flag(state, val) { + state.flag = val + } + }, + actions: { + async search(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var url_string = window.location.href + var url = new URL(url_string); + var status = url.searchParams.get("status"); + var xstartdate = url.searchParams.get("startdate"); + var xsearch = url.searchParams.get("search"); + var xflag = url.searchParams.get("flag"); + + // untuk notifikasi + if (xflag == 'N') { + + if (xsearch != null && xsearch != '') { + context.commit("updateFSearch", xsearch); + } + if (status != null && status != '') { + context.commit("updateFStatus", status); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedEndDate", xstartdate); + } + + } else if (xflag == 'G') { + // untuk get data param approve all + + if (status != null && status != '') { + context.commit("updateFStatus", status); + } + if (xstartdate != null && xstartdate != '') { + context.commit("updateFStartDate", xstartdate); + context.commit("updateFEndDate", moment(new Date()).format('YYYY-MM-DD')); + } + context.commit("update_flag", xflag); + + } + + var payload = { + token: one_token(), + currentPage: context.state.mainTableCurrentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus == 'All' ? "" : context.state.fStatus, + search: context.state.fSearch, + lastId: -1, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateMainTable", data.records); + context.commit("updateCountMainTable", data.total); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async getlevel(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var payload = { + token: one_token() + }; + + let response = await api.getlevel(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateLevelName", data.records[0].M_ApproveLevelName); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async searchDetail(context) { + context.commit("updateDetailTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + PRID: context.state.selectedMainTable.PurchaseRequestDirectID, + }; + + let response = await api.searchDetail(payload); + if (response.status != "OK") { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", response.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("updateDetailTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateDetailTable", data.records); + context.commit("updateCountDetailTable", data.total); + } + } catch (e) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", e.message); + } + }, + async updateDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateDetail(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request [${payload.PRDDescription}] telah diperbarui`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async rejectRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.rejectRequest(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request [${payload.PRNumber}] sudah ditolak`; + context.commit("updateSuccessMessage", msg); + context.commit("updateSelectedMainTable", {}); + context.commit("updateDetailTable", []); + context.commit("updateSelectedDetailTable", {}); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async unApproveRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.unApproveRequest(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request [${payload.PRNumber}] berhasil di unapprove`; + context.commit("updateSuccessMessage", msg); + context.commit("updateSelectedMainTable", {}); + context.commit("updateDetailTable", []); + context.commit("updateSelectedDetailTable", {}); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Request [${payload.PRDDescription}] sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async approveRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.approveRequest(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request [${payload.PRNumber}] telah diapprove`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + }, +}; diff --git a/test/vuex/acc-one-purchase-request-direct-approved/store.js b/test/vuex/acc-one-purchase-request-direct-approved/store.js new file mode 100644 index 0000000..dac7742 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct-approved/store.js @@ -0,0 +1,11 @@ +import manager from "./modules/manager.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + manager: manager, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-purchase-request-direct/api/api-requester.js b/test/vuex/acc-one-purchase-request-direct/api/api-requester.js new file mode 100644 index 0000000..f1b345a --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/api/api-requester.js @@ -0,0 +1,309 @@ +const URL = "/one-api/mockup/purchase/requester/"; + +export async function search(payload) { + try { + var response = await axios.post(URL + "PurchaseRequestDirect/search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/searchDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getRegional(payload) { + try { + var response = await axios.post(URL + "PurchaseRequestDirect/getRegional", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getBranch(payload) { + try { + var response = await axios.post(URL + "PurchaseRequestDirect/getBranch", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/saveRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/updateRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/deleteRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/saveDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/updateDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/deleteDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function orderRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/orderRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getUnit(token, prm) { + try { + var resp = await axios.post(URL + 'PurchaseRequestDirect/getUnit', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveFiles(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestDirect/saveFiles", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + + +export async function getCategoryPD(params) { + try { + var response = await axios.post(URL + 'PurchaseRequestDirect/PurchaseDirectCategory', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data; + return data + } catch (error) { + return { + status: "ERR", + message: error.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct/components/addPurchaseRequestDialog.vue b/test/vuex/acc-one-purchase-request-direct/components/addPurchaseRequestDialog.vue new file mode 100644 index 0000000..d339ce3 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/components/addPurchaseRequestDialog.vue @@ -0,0 +1,227 @@ + + + diff --git a/test/vuex/acc-one-purchase-request-direct/components/addRequestDetailDialog.vue b/test/vuex/acc-one-purchase-request-direct/components/addRequestDetailDialog.vue new file mode 100644 index 0000000..0b077eb --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/components/addRequestDetailDialog.vue @@ -0,0 +1,350 @@ + + + diff --git a/test/vuex/acc-one-purchase-request-direct/components/formAddRequestDetail.vue b/test/vuex/acc-one-purchase-request-direct/components/formAddRequestDetail.vue new file mode 100644 index 0000000..46accd5 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/components/formAddRequestDetail.vue @@ -0,0 +1,376 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct/components/formDialogAttachtment.vue b/test/vuex/acc-one-purchase-request-direct/components/formDialogAttachtment.vue new file mode 100644 index 0000000..c32d58a --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/components/formDialogAttachtment.vue @@ -0,0 +1,155 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct/components/oneDialogAlert.vue b/test/vuex/acc-one-purchase-request-direct/components/oneDialogAlert.vue new file mode 100644 index 0000000..b59be68 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/components/oneDialogAlert.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-request-direct/components/requestListing.vue b/test/vuex/acc-one-purchase-request-direct/components/requestListing.vue new file mode 100644 index 0000000..ab95951 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/components/requestListing.vue @@ -0,0 +1,1115 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-request-direct/index.php b/test/vuex/acc-one-purchase-request-direct/index.php new file mode 100644 index 0000000..2af0937 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/index.php @@ -0,0 +1,67 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-direct/modules/requester.js b/test/vuex/acc-one-purchase-request-direct/modules/requester.js new file mode 100644 index 0000000..2c8a6f7 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/modules/requester.js @@ -0,0 +1,655 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api-requester.js"; + +export default { + namespaced: true, + state: { + mainTable: [], + detailTable: [], + countMainTable: 0, + countDetailTable: 0, + mainTableLoadingStatus: 0, + detailTableLoadingStatus: 0, + mainTableErrorMessage: "", + detailTableErrorMessage: "", + mainTableCurrentPage: 1, + mainTableLastId: -1, + + selectedMainTable: {}, + selectedDetailTable: {}, + + statusOptions: [ + { value: 0, title: "All" }, + { value: 1, title: "Draft" }, + { value: 2, title: "Pending" }, + { value: 3, title: "Approved" }, + { value: 4, title: "Rejected" }, + { value: 5, title: "Paid" }, + { value: 6, title: "Completed" }, + ], + branchOptions: [], + regionalOptions: [], + + menuStartDate: false, + menuEndDate: false, + menuDateUse: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + fStatus: 0, + fSearch: "", + + dDateUse: new Date().toISOString().substring(0, 10), + xDateUse: moment(new Date()).format("YYYY-MM-DD"), + xRegional: "", + xBranch: "", + xDescription: "", + xPRID: 0, + xNumber: "", + xPRDID: 0, + xDescriptionDetail: "", + xAmountRequest: 0, + xEstimationPrice: 0, + + dialogRequest: false, + dialogDetail: false, + act: "new", + errMessage: "", + successMessage: "", + alertError: false, + alertSuccess: false, + errors: [], + total_price: 0, + item_units: [], + selected_item_unit: {}, + search_item_unit: "", + loadingAutocomplete: false, + dialog_form: false, + show_progrees_upload: false, + imageFiles: [], + imagePreviews: [], + cekFile: false, + actAttach: "", + + category_direct: [], + selected_category: {} + }, + mutations: { + updateMainTable(state, val) { + state.mainTable = val; + }, + updateDetailTable(state, val) { + state.detailTable = val; + }, + updateCountMainTable(state, val) { + state.countMainTable = val; + }, + updateCountDetailTable(state, val) { + state.countDetailTable = val; + }, + updateMainTableLoadingStatus(state, val) { + state.mainTableLoadingStatus = val; + }, + updateDetailTableLoadingStatus(state, val) { + state.detailTableLoadingStatus = val; + }, + updateMainTableErrorMessage(state, val) { + state.mainTableErrorMessage = val; + }, + updateDetailTableErrorMessage(state, val) { + state.detailTableErrorMessage = val; + }, + updateMainTableCurrentPage(state, val) { + state.mainTableCurrentPage = val; + }, + updateMainTableLastId(state, val) { + state.mainTableLastId = val; + }, + + updateSelectedMainTable(state, val) { + state.selectedMainTable = val; + }, + updateSelectedDetailTable(state, val) { + state.selectedDetailTable = val; + }, + + updateBranchOptions(state, val) { + state.branchOptions = val; + }, + + updateRegionalOptions(state, val) { + state.regionalOptions = val; + }, + + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + updateMenuDateUse(state, val) { + state.menuDateUse = val; + }, + + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateFStatus(state, val) { + state.fStatus = val; + }, + updateFSearch(state, val) { + state.fSearch = val; + }, + + updateDDateUse(state, val) { + state.dDateUse = val; + }, + updateXDateUse(state, val) { + state.xDateUse = val; + }, + updateXRegional(state, val) { + state.xRegional = val; + }, + updateXBranch(state, val) { + state.xBranch = val; + }, + updateXDescription(state, val) { + state.xDescription = val; + }, + updateXPRID(state, val) { + state.xPRID = val; + }, + updateXNumber(state, val) { + state.xNumber = val; + }, + updateXPRDID(state, val) { + state.xPRDID = val; + }, + updateXDescriptionDetail(state, val) { + state.xDescriptionDetail = val; + }, + updateXAmountRequest(state, val) { + state.xAmountRequest = val; + }, + updateXEstimationPrice(state, val) { + state.xEstimationPrice = val; + }, + + updateDialogRequest(state, val) { + state.dialogRequest = val; + }, + updateDialogDetail(state, val) { + state.dialogDetail = val; + }, + updateAct(state, val) { + state.act = val; + }, + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateSuccessMessage(state, val) { + state.successMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateAlertSuccess(state, val) { + state.alertSuccess = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + updateTotalPrice(state, val) { + state.total_price = val; + }, + updateItemUnits(state, val) { + state.item_units = val; + }, + updateSelectedItemUnit(state, val) { + state.selected_item_unit = val; + }, + updateSearchItemUnit(state, val) { + state.search_item_unit = val; + }, + updateLoadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + update_dialog_form(state, val) { + state.dialog_form = val; + }, + update_show_progrees_upload(state, val) { + state.show_progrees_upload = val + }, + update_imageFiles(state, val) { + state.imageFiles = val + }, + update_imagePreviews(state, val) { + state.imagePreviews = val + }, + update_cekFile(state, val) { + state.cekFile = val + }, + update_actAttach(state, val) { + state.actAttach = val + }, + update_category_direct(state, val) { + state.category_direct = val + }, + update_selected_category(state, val) { + state.selected_category = val + } + }, + actions: { + async getCategoryPD(context) { + context.commit("updateDetailTableLoadingStatus", 1); + try { + var params = { + token: one_token(), + name: '' + } + + let resp = await api.getCategoryPD(params) + if (resp.status != 'OK') { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", resp.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("update_category_direct", resp.data) + } + + } catch (error) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", error.message); + } + }, + async search(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var url_string = window.location.href + var url = new URL(url_string); + var xdate = url.searchParams.get("date"); + var xsearch = url.searchParams.get("search"); + + if (xsearch) { + context.commit("updateFSearch", xsearch); + } + if (xdate) { + context.commit("updateFStartDate", xdate); + context.commit("updateFEndDate", xdate); + } + + var payload = { + token: one_token(), + currentPage: context.state.mainTableCurrentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus, + search: context.state.fSearch, + lastId: -1, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateMainTable", data.records); + context.commit("updateCountMainTable", data.total); + context.dispatch("system/getlistnotif", null, { root: true }) + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async searchDetail(context) { + context.commit("updateDetailTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + PRID: context.state.selectedMainTable.PurchaseRequestDirectID, + }; + + let response = await api.searchDetail(payload); + if (response.status != "OK") { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", response.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("updateDetailTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateDetailTable", data.records); + context.commit("updateCountDetailTable", data.total); + } + } catch (e) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", e.message); + } + }, + async regional(context) { + let response = await api.getRegional({ token: one_token() }); + if (response.status === "OK") { + let data = { + records: response.data.records, + }; + + context.commit("updateRegionalOptions", data.records); + } + }, + async branch(context) { + let response = await api.getBranch({ token: one_token() }); + if (response.status === "OK") { + let data = { + records: response.data.records, + }; + + context.commit("updateBranchOptions", data.records); + } + }, + async saveRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.saveRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = `Purchase Request baru dengan kode ${data.records[0].PurchaseRequestDirectNumber} sudah tersimpan`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = `Perubahan Purchase Request dengan kode ${data.records[0].PurchaseRequestDirectNumber} sudah tersimpan`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = `Purchase Request dengan kode ${payload.PRNumber} sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async saveDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.saveDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request baru ${payload.PRDDescription} sudah tersimpan`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = "Perubahan Request sudah tersimpan"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request [${payload.PRDDescriptionDetail}] sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async orderRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.orderRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getUnit(context, prm) { + context.commit("updateLoadingAutocomplete", true) + try { + let resp = await api.getUnit(one_token(), prm) + if (resp.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", ""); + let data = { + records: resp.data.records + } + + context.commit("updateItemUnits", data.records) + } + } catch (e) { + context.commit("updateLoadingAutocomplete", true) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async saveFiles(context, payload) { + try { + // payload.token = one_token(); + + let response = await api.saveFiles(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + context.commit("update_cekFile", true); + } else { + context.commit("updateErrMessage", ""); + // let data = { + // records: response.data.records, + // total: response.data.total, + // }; + + context.commit("update_dialog_form", false); + context.commit("update_imageFiles", []); + context.commit("update_imagePreviews", []); + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = "Upload file berhasil"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + }, +}; diff --git a/test/vuex/acc-one-purchase-request-direct/store.js b/test/vuex/acc-one-purchase-request-direct/store.js new file mode 100644 index 0000000..347b5f0 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-direct/store.js @@ -0,0 +1,11 @@ +import requester from "./modules/requester.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + requester: requester, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-purchase-request-nonpersediaan/components/dialogConfirmHandover.vue b/test/vuex/acc-one-purchase-request-nonpersediaan/components/dialogConfirmHandover.vue index 7243f8a..6b02e0d 100644 --- a/test/vuex/acc-one-purchase-request-nonpersediaan/components/dialogConfirmHandover.vue +++ b/test/vuex/acc-one-purchase-request-nonpersediaan/components/dialogConfirmHandover.vue @@ -7,6 +7,17 @@

Apakah Anda yakin ingin melakukan konfirmasi terima barang inventaris ?

+ + NO + PENERIMA + BARCODE + + + {{ idx + 1 }} + {{ obj.M_UserUsername }} + {{ obj.T_BarcodeBarangNumber }} +
@@ -44,14 +55,22 @@ module.exports = { }, methods: { closeHandOver() { + this.selected_main = {} this.dialogConfirmHandover = false }, + itemNeedConfirming(data) { + return data.filter(item => item.allHandedOver == 'N'); + }, async saveConfirmHandOver() { + const dataHanded = this.selected_main.itemHandedOver; + const itemHanded = dataHanded.filter(item => item.allHandedOver == 'N'); + let prm = { purchaseRequestID: this.selected_main.prId, + itemHandedOver: itemHanded } await this.$store.dispatch("requester/confirmHandOver", prm); }, }, } - \ No newline at end of file + diff --git a/test/vuex/acc-one-purchase-request-nonpersediaan/components/requestListing.vue b/test/vuex/acc-one-purchase-request-nonpersediaan/components/requestListing.vue index 9c4d1fe..b1353a2 100644 --- a/test/vuex/acc-one-purchase-request-nonpersediaan/components/requestListing.vue +++ b/test/vuex/acc-one-purchase-request-nonpersediaan/components/requestListing.vue @@ -1,826 +1,697 @@ diff --git a/test/vuex/acc-one-purchase-request-persediaan/api/api.js b/test/vuex/acc-one-purchase-request-persediaan/api/api.js new file mode 100644 index 0000000..df3e84b --- /dev/null +++ b/test/vuex/acc-one-purchase-request-persediaan/api/api.js @@ -0,0 +1,425 @@ +const URL = "/one-api/mockup/purchase/requester/"; + +export async function search(payload) { + try { + var response = await axios.post(URL + "PurchaseRequestPersediaan/search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestPersediaan/searchDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getRegional(payload) { + try { + var response = await axios.post(URL + "PurchaseRequestPersediaan/getRegionalBranchByUser", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getBranch(payload) { + try { + var response = await axios.post(URL + "PurchaseRequestPersediaan/getBranch", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestPersediaan/saveRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestPersediaan/updateRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestPersediaan/deleteRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestPersediaan/saveDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestPersediaan/updateDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteDetail(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestPersediaan/deleteDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function orderRequest(payload) { + try { + var response = await axios.post( + URL + "PurchaseRequestPersediaan/orderRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getUnit(token, prm) { + try { + var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getUnit', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function getDivisionByUser(token) { + try { + var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getDivisionByUser', { + token: token + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function getItems(payload) { + try { + var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getItems', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getItemGroupSubGroup(payload) { + try { + var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getItemGroupSubGroup', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUnitByItemId(payload) { + try { + var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getUnitByItemId', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function savePurchaseRequest(payload) { + try { + var response = await axios.post(URL + 'PurchaseRequestPersediaan/savePurchaseRequest', payload); + if (response.status != 200) { + return { + status: "ERR", + message: response.statusText + }; + } + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveAndDoPurchaseRequest(payload){ + try { + var response = await axios.post(URL + 'PurchaseRequestPersediaan/saveAndDoPurchaseRequest', payload); + if (response.status != 200) { + return { + status: "ERR", + message: response.statusText + }; + } + let data = response.data; + return data; + } catch (e) { + + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAPI(fn,payload) { + try { + let urx = URL + 'PurchaseRequestPersediaan/'+fn; + console.log(urx); + var response = await axios.post(urx, payload); + if (response.status != 200) { + return { + status: "ERR", + message: response.statusText + }; + } + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getRiwayatItem(params) { + try { + var resp = await axios.post(URL + 'PurchaseRequestPersediaan/getRiwayatItem', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + diff --git a/test/vuex/acc-one-purchase-request-persediaan/components/addPurchaseRequestDialog.vue b/test/vuex/acc-one-purchase-request-persediaan/components/addPurchaseRequestDialog.vue new file mode 100644 index 0000000..05429f4 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-persediaan/components/addPurchaseRequestDialog.vue @@ -0,0 +1,848 @@ + + + diff --git a/test/vuex/acc-one-purchase-request-persediaan/components/addRequestDetailDialog.vue b/test/vuex/acc-one-purchase-request-persediaan/components/addRequestDetailDialog.vue new file mode 100644 index 0000000..60936d0 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-persediaan/components/addRequestDetailDialog.vue @@ -0,0 +1,280 @@ + + + diff --git a/test/vuex/acc-one-purchase-request-persediaan/components/dialogRiwayat.vue b/test/vuex/acc-one-purchase-request-persediaan/components/dialogRiwayat.vue new file mode 100644 index 0000000..2ddabbb --- /dev/null +++ b/test/vuex/acc-one-purchase-request-persediaan/components/dialogRiwayat.vue @@ -0,0 +1,89 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-persediaan/components/requestListing.vue b/test/vuex/acc-one-purchase-request-persediaan/components/requestListing.vue new file mode 100644 index 0000000..18dbd55 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-persediaan/components/requestListing.vue @@ -0,0 +1,793 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-request-persediaan/index.php b/test/vuex/acc-one-purchase-request-persediaan/index.php new file mode 100644 index 0000000..06e67ec --- /dev/null +++ b/test/vuex/acc-one-purchase-request-persediaan/index.php @@ -0,0 +1,118 @@ + + + + + + + + + + + One + + + + + + + + + Error + + + + {{errMessage}} + + + + + + + + Tutup + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-persediaan/modules/requester.js b/test/vuex/acc-one-purchase-request-persediaan/modules/requester.js new file mode 100644 index 0000000..fdd63ea --- /dev/null +++ b/test/vuex/acc-one-purchase-request-persediaan/modules/requester.js @@ -0,0 +1,976 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + mainTable: [], + detailTable: [], + countMainTable: 0, + countDetailTable: 0, + mainTableLoadingStatus: 0, + detailTableLoadingStatus: 0, + mainTableErrorMessage: "", + detailTableErrorMessage: "", + mainTableCurrentPage: 1, + mainTableLastId: -1, + + selectedMainTable: {}, + selectedDetailTable: {}, + + statusOptions: [ + { value: '', title: "All" }, + { value: 'draft', title: "Draft" }, + { value: 'pending', title: "Pending" }, + { value: 'approved', title: "Approved" }, + { value: 'rejected', title: "Rejected" }, + { value: 'paid', title: "Paid" }, + { value: 'completed', title: "Completed" }, + ], + branchOptions: [], + regionalOptions: [], + + menuStartDate: false, + menuEndDate: false, + menuDateUse: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + fStatus: '', + fSearch: "", + + dDateUse: new Date().toISOString().substring(0, 10), + xDateUse: moment(new Date()).format("YYYY-MM-DD"), + xRegional: "", + xBranch: "", + xDescription: "", + xPRID: 0, + xNumber: "", + xPRDID: 0, + xDescriptionDetail: "", + xAmountRequest: 0, + xEstimationPrice: 0, + + dialogRequest: false, + dialogDetail: false, + act: "new", + errMessage: "", + succesMessage: "", + alertError: false, + alertSuccess: false, + errors: [], + total_price: 0, + item_units: [], + selected_item_unit: {}, + search_item_unit: "", + loadingAutocomplete: false, + divisionOptions: [], + selectedDivision: {}, + itemCurrentPage: 1, + itemTotalPage: 0, + itemLastId: -1, + items: [], + selectedItems: [], + selectedItem: {}, + searchItem: "", + itemCurrentPage: 1, + itemTotalPage: 0, + loadingItem: false, + itemGroupOptions: [], + selectedItemGroup: {}, + loadingItemGroup: false, + itemSubGroupOptions: [], + selectedItemSubGroup: {}, + loadingItemSubGroup: false, + dialogUnit: false, + selectedUnit: {}, + unitOptions: [], + loadingUnit: false, + loadingSave: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + loadingDetailRequest: false, + + dialog_riwayat: false, + riwayat_item: {}, + user: one_user(), + }, + mutations: { + updateLoadingDetailRequest(state, val) { + state.loadingDetailRequest = val; + }, + updateSnackbar(state, val) { + state.snackbar = val; + }, + updateSelectedItem(state, val) { + state.selectedItem = val; + }, + updateLoadingSave(state, val) { + state.loadingSave = val; + }, + updateLoadingUnit(state, val) { + state.loadingUnit = val; + }, + updateDialogUnit(state, val) { + state.dialogUnit = val; + }, + updateSelectedUnit(state, val) { + state.selectedUnit = val; + }, + updateUnitOptions(state, val) { + state.unitOptions = val; + }, + updateItemCurrentPage(state, val) { + state.itemCurrentPage = val; + }, + updateItemTotalPage(state, val) { + state.itemTotalPage = val; + }, + updateItemLastId(state, val) { + state.itemLastId = val; + }, + updateDivisionOptions(state, val) { + state.divisionOptions = val; + }, + updateSelectedDivision(state, val) { + state.selectedDivision = val; + }, + updateMainTable(state, val) { + state.mainTable = val; + }, + updateDetailTable(state, val) { + state.detailTable = val; + }, + updateCountMainTable(state, val) { + state.countMainTable = val; + }, + updateCountDetailTable(state, val) { + state.countDetailTable = val; + }, + updateMainTableLoadingStatus(state, val) { + state.mainTableLoadingStatus = val; + }, + updateDetailTableLoadingStatus(state, val) { + state.detailTableLoadingStatus = val; + }, + updateMainTableErrorMessage(state, val) { + state.mainTableErrorMessage = val; + }, + updateDetailTableErrorMessage(state, val) { + state.detailTableErrorMessage = val; + }, + updateMainTableCurrentPage(state, val) { + state.mainTableCurrentPage = val; + }, + updateMainTableLastId(state, val) { + state.mainTableLastId = val; + }, + + updateSelectedMainTable(state, val) { + state.selectedMainTable = val; + }, + updateSelectedDetailTable(state, val) { + state.selectedDetailTable = val; + }, + + updateBranchOptions(state, val) { + state.branchOptions = val; + }, + + updateRegionalOptions(state, val) { + state.regionalOptions = val; + }, + + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + updateMenuDateUse(state, val) { + state.menuDateUse = val; + }, + + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateFStatus(state, val) { + state.fStatus = val; + }, + updateFSearch(state, val) { + state.fSearch = val; + }, + + updateDDateUse(state, val) { + state.dDateUse = val; + }, + updateXDateUse(state, val) { + state.xDateUse = val; + }, + updateXRegional(state, val) { + state.xRegional = val; + }, + updateXBranch(state, val) { + state.xBranch = val; + }, + updateXDescription(state, val) { + state.xDescription = val; + }, + updateXPRID(state, val) { + state.xPRID = val; + }, + updateXNumber(state, val) { + state.xNumber = val; + }, + updateXPRDID(state, val) { + state.xPRDID = val; + }, + updateXDescriptionDetail(state, val) { + state.xDescriptionDetail = val; + }, + updateXAmountRequest(state, val) { + state.xAmountRequest = val; + }, + updateXEstimationPrice(state, val) { + state.xEstimationPrice = val; + }, + + updateDialogRequest(state, val) { + state.dialogRequest = val; + }, + updateDialogDetail(state, val) { + state.dialogDetail = val; + }, + updateAct(state, val) { + state.act = val; + }, + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateSuccessMessage(state, val) { + state.successMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateAlertSuccess(state, val) { + state.alertSuccess = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + updateTotalPrice(state, val) { + state.total_price = val; + }, + updateItemUnits(state, val) { + state.item_units = val; + }, + updateSelectedItemUnit(state, val) { + state.selected_item_unit = val; + }, + updateSearchItemUnit(state, val) { + state.search_item_unit = val; + }, + updateLoadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + updateItems(state, val) { + state.items = val; + }, + updateSelectedItems(state, val) { + state.selectedItems = val; + }, + updateSearchItem(state, val) { + state.searchItem = val; + }, + updateLoadingItem(state, val) { + state.loadingItem = val; + }, + updateItemGroupOptions(state, val) { + state.itemGroupOptions = val; + }, + updateSelectedItemGroup(state, val) { + state.selectedItemGroup = val; + }, + updateItemSubGroupOptions(state, val) { + state.itemSubGroupOptions = val; + }, + updateSelectedItemSubGroup(state, val) { + state.selectedItemSubGroup = val; + }, + updateLoadingItemGroup(state, val) { + state.loadingItemGroup = val; + }, + updateLoadingItemSubGroup(state, val) { + state.loadingItemSubGroup = val; + }, + update_dialog_riwayat(state, val) { + state.dialog_riwayat = val; + }, + update_riwayat_item(state, val) { + state.riwayat_item = val + }, + updateUser(state, val) { + state.user = val + } + }, + actions: { + async search(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var url_string = window.location.href + var url = new URL(url_string); + var xdate = url.searchParams.get("date"); + var xsearch = url.searchParams.get("search"); + + if (xsearch) { + context.commit("updateFSearch", xsearch); + } + if (xdate) { + context.commit("updateFStartDate", xdate); + context.commit("updateFEndDate", xdate); + } + + var payload = { + token: one_token(), + currentPage: context.state.mainTableCurrentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus, + search: context.state.fSearch, + lastId: -1, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateMainTable", data.records); + context.commit("updateCountMainTable", data.total); + context.dispatch("system/getlistnotif", null, { root: true }) + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async searchDetail(context) { + context.commit("updateDetailTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + PRID: context.state.selectedMainTable.PurchaseRequestID, + }; + + let response = await api.searchDetail(payload); + if (response.status != "OK") { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", response.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("updateDetailTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateDetailTable", data.records); + context.commit("updateCountDetailTable", data.total); + } + } catch (e) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", e.message); + } + }, + async regional(context) { + let response = await api.getRegional({ token: one_token() }); + if (response.status === "OK") { + let data = { + records: response.data.records, + }; + + context.commit("updateRegionalOptions", data.records); + } + }, + async branch(context) { + let response = await api.getBranch({ token: one_token() }); + if (response.status === "OK") { + let data = { + records: response.data.records, + }; + + context.commit("updateBranchOptions", data.records); + } + }, + async saveRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.saveRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = `Purchase Request baru dengan kode ${data.records[0].PurchaseRequestDirectNumber} sudah tersimpan`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = `Perubahan Purchase Request dengan kode ${data.records[0].PurchaseRequestDirectNumber} sudah tersimpan`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.getAPI('deletePurchaseRequest',payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = `Purchase Request dengan kode ${payload.PRNumber} sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async saveDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.saveDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request baru ${payload.PRDDescription} sudah tersimpan`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = "Perubahan Request sudah tersimpan"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request [${payload.PRDDescriptionDetail}] sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async orderRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.orderRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getUnit(context, prm) { + context.commit("updateLoadingAutocomplete", true) + try { + let resp = await api.getUnit(one_token(), prm) + if (resp.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", ""); + let data = { + records: resp.data.records + } + + context.commit("updateItemUnits", data.records) + } + } catch (e) { + context.commit("updateLoadingAutocomplete", true) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getDivisionByUser(context) { + context.commit("updateLoadingAutocomplete", true) + try { + let response = await api.getDivisionByUser({ token: one_token() }); + if (response.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + let data = { + records: response.data.records, + selected: response.data.selected + }; + context.commit("updateDivisionOptions", data.records); + context.commit("updateSelectedDivision", data.selected); + context.dispatch("getItemGroupSubGroup",data.selected); + } + } catch (e) { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getItemGroupSubGroup(context, payload) { + context.commit("updateLoadingItemGroup", true) + context.commit("updateLoadingItemSubGroup", true) + try { + let response = await api.getItemGroupSubGroup({ token: one_token(), division: payload.M_DivisionID ? payload.M_DivisionID : "" }); + if (response.status != "OK") { + context.commit("updateLoadingItemGroup", false) + context.commit("updateLoadingItemSubGroup", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItemGroup", false) + context.commit("updateLoadingItemSubGroup", false) + context.commit("updateErrMessage", ""); + context.commit("updateItemGroupOptions", response.data.records); + context.commit("updateSelectedItemGroup", response.data.records[0]); + context.commit("updateItemSubGroupOptions", response.data.records[0].subGroups); + context.commit("updateSelectedItemSubGroup", response.data.records[0].subGroups[0]); + + /*let division = payload.M_DivisionID ? payload.M_DivisionID : ""; + let itemGroup = response.data.records[0].Nat_GroupID ? response.data.records[0].Nat_GroupID : ""; + let itemSubGroup = response.data.records[0].subGroups[0].Nat_SubGroupID ? response.data.records[0].subGroups[0].Nat_SubGroupID : ""; + + let payload = { + search: "", + division: division, + itemGroup: itemGroup, + itemSubGroup: itemSubGroup + }; + context.dispatch("getItems", payload);*/ + } + } catch (e) { + context.commit("updateLoadingItemGroup", false) + context.commit("updateLoadingItemSubGroup", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getItems(context, payload) { + context.commit("updateLoadingItem", true) + try { + payload.token = one_token(); + payload.currentPage = context.state.itemCurrentPage; + let response = await api.getItems(payload); + if (response.status != "OK") { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", ""); + context.commit("updateItems", response.data.records); + context.commit("updateItemTotalPage", response.data.total); + if(!isEmpty(context.state.selectedMainTable)) { + context.dispatch("getSelectedItem", context.state.selectedMainTable); + } + } + } catch (e) { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getSelectedItem(context, payload) { + try { + payload.token = one_token(); + let response = await api.getSelectedItem(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + context.commit("updateSelectedItem", response.data.records); + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getUnitByItemId(context, payload) { + context.commit("updateLoadingUnit", true) + context.commit("updateDialogUnit", true); + try { + payload.token = one_token(); + let response = await api.getUnitByItemId(payload); + if (response.status != "OK") { + context.commit("updateLoadingUnit", false) + context.commit("updateDialogUnit", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingUnit", false) + context.commit("updateErrMessage", ""); + context.commit("updateUnitOptions", response.data.records); + context.commit("updateSelectedUnit", payload.selectedUnit); + + } + } catch (e) { + context.commit("updateLoadingUnit", false) + context.commit("updateDialogUnit", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getGroupByDivision(context, payload) { + context.commit("updateLoadingItemGroup", true) + try { + let response = await api.getGroupByDivision(payload); + if (response.status != "OK") { + context.commit("updateLoadingItemGroup", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItemGroup", false) + context.commit("updateErrMessage", ""); + context.commit("updateItemGroupOptions", response.data.records); + context.commit("updateSelectedItemGroup", response.data.records[0]); + } + } catch (e) { + context.commit("updateLoadingItemGroup", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async savePurchaseRequest(context, payload) { + context.commit("updateLoadingSave", true); + try { + payload.token = one_token(); + let response = await api.savePurchaseRequest(payload); + if (response.status != "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateDialogRequest", false); + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Purchase Request berhasil disimpan', + }); + console.log(context.state.snackbar); + context.commit("updateSelectedItems", []); + context.commit("updateSelectedItem", {}); + context.commit("updateItems", []); + context.commit("updateItemTotalPage", 0); + context.commit("updateItemCurrentPage", 1); + context.commit("updateItemLastId", -1); + context.dispatch("search"); + } + + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async updatePurchaseRequest(context, payload) { + context.commit("updateLoadingSave", true); + try { + payload.token = one_token(); + let response = await api.getAPI('updatePurchaseRequest',payload); + if (response.status != "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateDialogRequest", false); + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Purchase Request '+payload.PRNumber+' berhasil diupdate', + }); + console.log(context.state.snackbar); + context.commit("updateSelectedItems", []); + context.commit("updateSelectedItem", {}); + context.commit("updateItems", []); + context.commit("updateItemLastId", -1); + context.dispatch("search"); + } + + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async saveAndDoPurchaseRequest(context, payload) { + context.commit("updateLoadingSave", true); + try { + payload.token = one_token(); + + let response = await api.saveAndDoPurchaseRequest(payload); + if (response.status !== "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateDialogRequest", false); + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Purchase Request berhasil disimpan dan diajukan', + }); + console.log(context.state.snackbar); + context.commit("updateSelectedItems", []); + context.commit("updateSelectedItem", {}); + context.commit("updateItems", []); + context.commit("updateItemTotalPage", 0); + context.commit("updateItemCurrentPage", 1); + context.commit("updateItemLastId", -1); + context.dispatch("search"); + context.dispatch("system/getlistnotif", null, { root: true }) + } + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getDetailRequest(context, payload) { + context.commit("updateLoadingDetailRequest", true) + try { + payload.token = one_token(); + let response = await api.getAPI('getDetailRequest',payload); + if (response.status != "OK") { + context.commit("updateLoadingDetailRequest", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateSelectedItems", response.data.records); + context.commit("updateLoadingDetailRequest", false) + } + } catch (e) { + context.commit("updateLoadingDetailRequest", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getRegionalBranchByUser(context) { + console.log("getRegionalBranchByUser"); + let response = await api.getAPI('getRegionalBranchByUser',{ token: one_token() }); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateBranchOptions", response.data); + } + }, + + async getRiwayatItem(context, params) { + try { + params.token = one_token() + params.page = 1 + + let resp = await api.getRiwayatItem(params) + if (resp.status != 'OK') { + context.commit("updateErrMessage", resp.message); + context.commit("updateAlertError", true); + } else { + context.commit("update_riwayat_item", resp.data) + } + } catch (error) { + context.commit("updateErrMessage", error.message); + context.commit("updateAlertError", true); + } + } + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-persediaan/store.js b/test/vuex/acc-one-purchase-request-persediaan/store.js new file mode 100644 index 0000000..347b5f0 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-persediaan/store.js @@ -0,0 +1,11 @@ +import requester from "./modules/requester.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + requester: requester, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-purchase-request-po-np-approved/api/api-manager.js b/test/vuex/acc-one-purchase-request-po-np-approved/api/api-manager.js new file mode 100644 index 0000000..d479cf5 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-po-np-approved/api/api-manager.js @@ -0,0 +1,136 @@ +const URL = "/one-api/mockup/purchase/manager/"; + +export async function search(payload) { + try { + var response = await axios.post(URL + "purchaseRequest/search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/searchDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/deleteDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approveRequest(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/approveRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function rejectRequest(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/rejectRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/updateDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} diff --git a/test/vuex/acc-one-purchase-request-po-np-approved/api/prkcab.js b/test/vuex/acc-one-purchase-request-po-np-approved/api/prkcab.js new file mode 100644 index 0000000..2602e98 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-po-np-approved/api/prkcab.js @@ -0,0 +1,98 @@ +const URL = "/one-api/mockup/nonpersediaanapproved/nonpersediaanapproved/"; +// https://accone.aplikasi.web.id/one-api/mockup/purchaserequestkacab/purchaserequestkacab/search + +export async function search(payload) { + try { + var response = await axios.post(URL + "search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getlevel(payload) { + try { + var response = await axios.post(URL + "getlevel", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getDetail(payload) { + try { + var response = await axios.post(URL + "getDetail", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function approve(payload) { + try { + var response = await axios.post(URL + "approve", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateqty(payload) { + try { + var response = await axios.post(URL + "updateqty", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-po-np-approved/components/acconeprkacab.vue b/test/vuex/acc-one-purchase-request-po-np-approved/components/acconeprkacab.vue new file mode 100644 index 0000000..62edd95 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-po-np-approved/components/acconeprkacab.vue @@ -0,0 +1,911 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-request-po-np-approved/components/requestListing.vue b/test/vuex/acc-one-purchase-request-po-np-approved/components/requestListing.vue new file mode 100644 index 0000000..12dd568 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-po-np-approved/components/requestListing.vue @@ -0,0 +1,905 @@ + + + + + diff --git a/test/vuex/acc-one-purchase-request-po-np-approved/index.php b/test/vuex/acc-one-purchase-request-po-np-approved/index.php new file mode 100644 index 0000000..3647bc2 --- /dev/null +++ b/test/vuex/acc-one-purchase-request-po-np-approved/index.php @@ -0,0 +1,68 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-purchase-request-po-np-approved/modules/manager.js b/test/vuex/acc-one-purchase-request-po-np-approved/modules/manager.js new file mode 100644 index 0000000..ebcc22b --- /dev/null +++ b/test/vuex/acc-one-purchase-request-po-np-approved/modules/manager.js @@ -0,0 +1,353 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api-manager.js"; + +export default { + namespaced: true, + state: { + mainTable: [], + detailTable: [], + countMainTable: 0, + countDetailTable: 0, + mainTableLoadingStatus: 0, + detailTableLoadingStatus: 0, + mainTableErrorMessage: "", + detailTableErrorMessage: "", + mainTableCurrentPage: 1, + mainTableLastId: -1, + + selectedMainTable: {}, + selectedDetailTable: {}, + + statusOptions: [ + { value: 0, title: "All" }, + { value: 2, title: "Pending" }, + { value: 3, title: "Approved" }, + { value: 4, title: "Rejected" }, + { value: 5, title: "Paid" }, + { value: 6, title: "Completed" }, + ], + + menuStartDate: false, + menuEndDate: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + fStatus: 0, + fSearch: "", + + xNote: "", + xAmount: 0, + xPRID: 0, + xPRDID: 0, + xStatus: "", + xDescriptionDetail: "", + + dialogDetail: false, + errMessage: "", + succesMessage: "", + alertError: false, + alertSuccess: false, + errors: [], + }, + mutations: { + updateMainTable(state, val) { + state.mainTable = val; + }, + updateDetailTable(state, val) { + state.detailTable = val; + }, + updateCountMainTable(state, val) { + state.countMainTable = val; + }, + updateCountDetailTable(state, val) { + state.countDetailTable = val; + }, + updateMainTableLoadingStatus(state, val) { + state.mainTableLoadingStatus = val; + }, + updateDetailTableLoadingStatus(state, val) { + state.detailTableLoadingStatus = val; + }, + updateMainTableErrorMessage(state, val) { + state.mainTableErrorMessage = val; + }, + updateDetailTableErrorMessage(state, val) { + state.detailTableErrorMessage = val; + }, + updateMainTableCurrentPage(state, val) { + state.mainTableCurrentPage = val; + }, + updateMainTableLastId(state, val) { + state.mainTableLastId = val; + }, + + updateSelectedMainTable(state, val) { + state.selectedMainTable = val; + }, + updateSelectedDetailTable(state, val) { + state.selectedDetailTable = val; + }, + + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateFStatus(state, val) { + state.fStatus = val; + }, + updateFSearch(state, val) { + state.fSearch = val; + }, + + updateXNote(state, val) { + state.xNote = val; + }, + updateXAmount(state, val) { + state.xAmount = val; + }, + updateXPRID(state, val) { + state.xPRID = val; + }, + updateXPRDID(state, val) { + state.xPRDID = val; + }, + updateXStatus(state, val) { + state.xStatus = val; + }, + updateXDescriptionDetail(state, val) { + state.xDescriptionDetail = val; + }, + + updateDialogDetail(state, val) { + state.dialogDetail = val; + }, + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateSuccessMessage(state, val) { + state.successMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateAlertSuccess(state, val) { + state.alertSuccess = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + }, + actions: { + async search(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + currentPage: context.state.mainTableCurrentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus, + search: context.state.fSearch, + lastId: -1, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateMainTable", data.records); + context.commit("updateCountMainTable", data.total); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async searchDetail(context) { + context.commit("updateDetailTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + PRID: context.state.selectedMainTable.PurchaseRequestDirectID, + }; + + let response = await api.searchDetail(payload); + if (response.status != "OK") { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", response.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("updateDetailTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateDetailTable", data.records); + context.commit("updateCountDetailTable", data.total); + } + } catch (e) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", e.message); + } + }, + async updateDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateDetail(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request [${payload.PRDDescription}] telah diperbarui`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async rejectRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.rejectRequest(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request [${payload.PRNumber}] sudah ditolak`; + context.commit("updateSuccessMessage", msg); + context.commit("updateSelectedMainTable", {}); + context.commit("updateDetailTable", []); + context.commit("updateSelectedDetailTable", {}); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Request [${payload.PRDDescription}] sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async approveRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.approveRequest(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request [${payload.PRNumber}] telah diapprove`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + }, +}; diff --git a/test/vuex/acc-one-purchase-request-po-np-approved/modules/prkacab.js b/test/vuex/acc-one-purchase-request-po-np-approved/modules/prkacab.js new file mode 100644 index 0000000..b7b5c5d --- /dev/null +++ b/test/vuex/acc-one-purchase-request-po-np-approved/modules/prkacab.js @@ -0,0 +1,357 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/prkcab.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + statusOptions: [ + { value: 'All', title: "All" }, + { value: 'Draft', title: "Draft" }, + { value: 'Pending', title: "Pending" }, + { value: 'Approved', title: "Approved" }, + { value: 'Rejected', title: "Rejected" }, + { value: 'Terkirim', title: "Terkirim" }, + { value: 'Partial', title: "Partial" }, + { value: 'Selesai', title: "Selesai" }, + ], + selectedStatus: { value: 'All', title: "All" }, + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + selectedEndDate: moment(new Date()).format('YYYY-MM-DD'), + search: '', + totalPage: 0, + selectedPage: 1, + loading: false, + prList: [], + dialogApprove: false, + detailData: [], + selectedPr: {}, + loadingDetail: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + levelname: [], + user_approvelevel: {}, + status: '', + xstartdate: '', + act_dialog: '', + dialogQty: false, + selectedItems: [], + flag: '', + }, + mutations: { + updateLevelName(state, val) { + state.levelname = val; + }, + update_snackbar(state, val) { + state.snackbar = val; + }, + update_loadingDetail(state, val) { + state.loadingDetail = val; + }, + update_selectedPr(state, val) { + state.selectedPr = val; + }, + update_detailData(state, val) { + state.detailData = val; + }, + update_dialogApprove(state, val) { + state.dialogApprove = val; + }, + update_selectedStatus(state, val) { + state.selectedStatus = val; + }, + update_selectedDate(state, val) { + state.selectedDate = val; + }, + update_selectedEndDate(state, val) { + state.selectedEndDate = val; + }, + update_search(state, val) { + state.search = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_totalPage(state, val) { + state.totalPage = val; + }, + update_selectedPage(state, val) { + state.selectedPage = val; + }, + update_prList(state, val) { + state.prList = val; + }, + updatte_user_approvelevel(state, val) { + state.user_approvelevel = val + }, + update_status(state, val) { + state.status = val + }, + update_xstartdate(state, val) { + state.xstartdate = val + }, + update_act_dialog(state, val) { + state.act_dialog = val + }, + update_dialogQty(state, val) { + state.dialogQty = val + }, + update_selectedItems(state, val) { + state.selectedItems = val; + }, + update_flag(state, val) { + state.flag = val + }, + }, + actions: { + async search(context) { + context.commit("update_loading", true); + + try { + + var url_string = window.location.href + var url = new URL(url_string); + var status = url.searchParams.get("status"); + var xstartdate = url.searchParams.get("startdate"); + var xsearch = url.searchParams.get("search"); + var xflag = url.searchParams.get("flag"); + + // untuk notifikasi + if (xflag == 'N') { + + if (xsearch != null && xsearch != '') { + context.commit("update_search", xsearch); + } + if (status != null && status != '') { + context.commit("update_selectedStatus", { value: status, title: status }); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedEndDate", xstartdate); + } + + } else if (xflag == 'G') { + // untuk get data param approve all + + if (status != null && status != '') { + context.commit("update_selectedStatus", { value: status, title: status }); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedEndDate", moment(new Date()).format('YYYY-MM-DD')); + } + context.commit("update_flag", xflag); + + } + + var payload = { + token: one_token(), + search: context.state.search, + startDate: context.state.selectedDate, + endDate: context.state.selectedEndDate, + status: context.state.selectedStatus.value, + page: context.state.selectedPage, + flag: context.state.flag, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("update_totalPage", data.total); + context.commit("update_prList", data.records); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + async approve(context, prm) { + context.commit("update_loading", true); + try { + prm.token = one_token() + let response = await api.approve(prm); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + // context.commit("update_totalPage", data.total); + // context.commit("update_prList", data.records); + await context.dispatch("search"); + context.commit("update_dialogApprove", false); + let msg = ''; + if (prm.type === 'A') { + msg = 'Berhasil approve purchase request ' + prm.pr.prNumber + } else if (prm.type === 'R') { + msg = 'Berhasil reject purchase request ' + prm.pr.prNumber + } else if (prm.type === 'U') { + msg = 'Berhasil unapprove purchase request ' + prm.pr.prNumber + } + let snackbar = { + state: true, + type: "success", + message: msg, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + async getlevel(context) { + context.commit("update_loadingDetail", true); + + try { + var payload = { + token: one_token()}; + + let response = await api.getlevel(payload); + if (response.status != "OK") { + context.commit("update_loadingDetail", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + context.commit("updateLevelName", data.records[0].M_ApproveLevelName); + context.commit("updatte_user_approvelevel", data.records[0]) + context.commit("update_loadingDetail", false); + } + } catch (e) { + context.commit("update_loadingDetail", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + async getDetail(context) { + context.commit("update_loadingDetail", true); + + try { + var payload = { + token: one_token(), + id: context.state.selectedPr.prID, + + }; + + let response = await api.getDetail(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingDetail", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_detailData", response.data); + context.commit("update_loadingDetail", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingDetail", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + async updateqty(context, prm) { + context.commit("update_loading", true); + try { + prm.token = one_token() + let response = await api.updateqty(prm); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + // context.commit("update_totalPage", data.total); + // context.commit("update_prList", data.records); + await context.dispatch("search"); + context.commit("update_dialogQty", false); + context.commit("update_detailData", []); + let msg = 'Berhasil edit qty'; + let snackbar = { + state: true, + type: "success", + message: msg, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + }, +}; diff --git a/test/vuex/acc-one-purchase-request-po-np-approved/store.js b/test/vuex/acc-one-purchase-request-po-np-approved/store.js new file mode 100644 index 0000000..2e01b2b --- /dev/null +++ b/test/vuex/acc-one-purchase-request-po-np-approved/store.js @@ -0,0 +1,14 @@ +import manager from "./modules/manager.js"; +import system from "../../../apps/modules/system/system.js"; +import prkacab from "./modules/prkacab.js" + +export const store = new Vuex.Store({ + modules: { + manager: manager, + system: system, + prkacab: prkacab + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-receive-item-po-inventaris/components/dialogPrintBarcode.vue b/test/vuex/acc-one-receive-item-po-inventaris/components/dialogPrintBarcode.vue index c4598fd..f0c362b 100644 --- a/test/vuex/acc-one-receive-item-po-inventaris/components/dialogPrintBarcode.vue +++ b/test/vuex/acc-one-receive-item-po-inventaris/components/dialogPrintBarcode.vue @@ -11,7 +11,7 @@ ITEM RUANGAN - NOMOR BARCODE + NUMBER BARCODE CETAK diff --git a/test/vuex/acc-one-receive-item-po-v2/api/api.js b/test/vuex/acc-one-receive-item-po-v2/api/api.js new file mode 100644 index 0000000..2744628 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/api/api.js @@ -0,0 +1,267 @@ +const URL = "/one-api/mockup/receive-item-po/ReceiveItemPoV2"; + +export async function search(params) { + try { + var resp = await axios.post(URL + '/searchRO', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getSupplier(params) { + try { + var resp = await axios.post(URL + '/getSupplier', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getPurchaseOrder(params) { + try { + var resp = await axios.post(URL + '/getPurchaseOrder', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getWarehouse(params) { + try { + var resp = await axios.post(URL + '/getWarehouse', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItem(params) { + try { + var resp = await axios.post(URL + '/getItem', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemUpdate(params) { + try { + var resp = await axios.post(URL + '/getItemUpdate', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveRO(params) { + try { + var resp = await axios.post(URL + '/saveRO', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function confirmRO(params) { + try { + var resp = await axios.post(URL + '/confirmRO', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function deleteRO(params) { + try { + var resp = await axios.post(URL + '/deleteRO', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveInspeksi(params) { + try { + var resp = await axios.post(URL + '/saveInspeksi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getItemDataInspeksi(params) { + try { + var resp = await axios.post(URL + '/getItemDataInspeksi', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListStaff(params) { + try { + var resp = await axios.post(URL + "/getListStaff", params) + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function saveEditRO(params) { + try { + var resp = await axios.post(URL + '/saveEditRO', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function template(params) { + try { + var resp = await axios.post(URL + '/', params); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/components/dialogBatchItem.vue b/test/vuex/acc-one-receive-item-po-v2/components/dialogBatchItem.vue new file mode 100644 index 0000000..7c2a5af --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/components/dialogBatchItem.vue @@ -0,0 +1,206 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/components/dialogRoLayout.vue b/test/vuex/acc-one-receive-item-po-v2/components/dialogRoLayout.vue new file mode 100644 index 0000000..9504d51 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/components/dialogRoLayout.vue @@ -0,0 +1,96 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/components/dialogSelectItem.vue b/test/vuex/acc-one-receive-item-po-v2/components/dialogSelectItem.vue new file mode 100644 index 0000000..e2d8aec --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/components/dialogSelectItem.vue @@ -0,0 +1,317 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/components/dialogViewRO.vue b/test/vuex/acc-one-receive-item-po-v2/components/dialogViewRO.vue new file mode 100644 index 0000000..c887c79 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/components/dialogViewRO.vue @@ -0,0 +1,247 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/components/formInspection.vue b/test/vuex/acc-one-receive-item-po-v2/components/formInspection.vue new file mode 100644 index 0000000..7512328 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/components/formInspection.vue @@ -0,0 +1,260 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/components/formReceiveItem.vue b/test/vuex/acc-one-receive-item-po-v2/components/formReceiveItem.vue new file mode 100644 index 0000000..944caa2 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/components/formReceiveItem.vue @@ -0,0 +1,433 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/components/formReceiveItemEdit.vue b/test/vuex/acc-one-receive-item-po-v2/components/formReceiveItemEdit.vue new file mode 100644 index 0000000..3127c65 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/components/formReceiveItemEdit.vue @@ -0,0 +1,376 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/components/oneRoLayout.vue b/test/vuex/acc-one-receive-item-po-v2/components/oneRoLayout.vue new file mode 100644 index 0000000..daa78f5 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/components/oneRoLayout.vue @@ -0,0 +1,307 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/index.php b/test/vuex/acc-one-receive-item-po-v2/index.php new file mode 100644 index 0000000..0254d88 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/index.php @@ -0,0 +1,104 @@ + + + + + + + ACCONE | Receive Item PO + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/modules/form.js b/test/vuex/acc-one-receive-item-po-v2/modules/form.js new file mode 100644 index 0000000..85c5794 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/modules/form.js @@ -0,0 +1,352 @@ +import * as api from "../api/api.js" + +export default { + namespaced: true, + state: { + dialog_form_receive_item: false, + dialog_form_receive_item_edit: false, + dialog_select_item: false, + dialog_batch_item: false, + form_receive: { + receive_date: moment(new Date()).format('YYYY-MM-DD'), + number_do: '', + referensi: '', + supplier: {}, + warehouse: {}, + shipping_cost: 0, + note: '' + }, + form_receive_item: [], + select_item_temp: [], + form_receive_item_del: [], + selected_po: {}, + list_po: [], + list_item_po: [], + shipping_info: [], + selected_item_forbatch: {}, + item_batch_temp: [], + + dialog_form_inspeksi: false, + selected_item_received: {}, + form_inspeksi: { + qty_po: 0, + qty_ro: 0, + price_po: 0.00, + price_ro: 0.00, + date_po: moment(new Date()).format('YYYY-MM-DD'), + date_ro: moment(new Date()).format('YYYY-MM-DD'), + expire_date: moment(new Date()).format('YYYY-MM-DD'), + condt_kemasan: '', + catatan_kemasan: '', + condt_pengiriman: '', + catatan_kirim: '', + summary: '', + catatan: '', + pemeriksa: '', + pengirim: '' + } + }, + mutations: { + update_dialog_form_receive_item(state, data) { + state.dialog_form_receive_item = data + }, + update_dialog_form_receive_item_edit(state, data) { + state.dialog_form_receive_item_edit = data + }, + update_dialog_select_item(state, data) { + state.dialog_select_item = data + }, + update_dialog_batch_item(state, data) { + state.dialog_batch_item = data + }, + update_form_receive(state, val) { + state.form_receive = val + }, + update_form_receive_item(state, val) { + state.form_receive_item = val + }, + update_form_receive_item_del(state, val) { + state.form_receive_item_del = val + }, + update_select_item_temp(state, val) { + state.select_item_temp = val + }, + update_selected_po(state, val) { + state.selected_po = val + }, + update_list_po(state, val) { + state.list_po = val + }, + update_list_item_po(state, val) { + state.list_item_po = val + }, + update_shipping_info(state, val) { + state.shipping_info = val + }, + update_selected_item_forbatch(state, val) { + state.selected_item_forbatch = val + }, + update_item_batch_temp(state, val) { + state.item_batch_temp = val + }, + update_dialog_form_inspeksi(state, val) { + state.dialog_form_inspeksi = val + }, + update_form_inspeksi(state, val) { + state.form_inspeksi = val + }, + update_selected_item_received(state, val) { + state.selected_item_received = val + } + }, + actions: { + resetForm(context) { + const form_receive = { + receive_date: moment(new Date()).format('YYYY-MM-DD'), + number_do: '', + referensi: '', + supplier: {}, + warehouse: {}, + shipping_cost: 0, + note: '' + } + + context.state.form_receive = form_receive + context.state.form_receive_item = [] + context.state.shipping_info = [] + }, + + async getPurchaseOrder(context) { + try { + let param = { + token: one_token(), + SupplierID: context.state.form_receive.supplier.SupplierID, + search: '', + localPO_deleted: context.state.form_receive_item_del.map(item => item.PoItemReceiveID) + } + const resp = await api.getPurchaseOrder(param); + if (resp.status != 'OK') { + context.commit("ro/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, {root: true}); + } else { + context.commit("update_list_po", resp.data); + } + } catch (error) { + context.commit("ro/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, {root: true}); + } + }, + + async getItem(context) { + try { + let param = { + token: one_token(), + POID: context.state.selected_po.PurchaseOrderID, + WarehouseID: context.state.form_receive.warehouse.WarehouseID + } + const resp = await api.getItem(param); + if (resp.status != 'OK') { + context.commit("ro/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, {root: true}); + } else { + context.commit("update_list_item_po", resp.data); + } + } catch (error) { + context.commit("ro/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, {root: true}); + } + }, + + async saveRO(context) { + try { + const cekShipping = context.state.shipping_info.some(item => item.isUpfront === 'N'); + let param = { + token: one_token(), + date: context.state.form_receive.receive_date, + supplierID: context.state.form_receive.supplier.SupplierID, + warehouseID: context.state.form_receive.warehouse.WarehouseID, + shippingCost: context.state.form_receive.shipping_cost, + shippingIsPaid: cekShipping ? 'N' : 'Y', + note: context.state.form_receive.note, + refNumber: context.state.form_receive.referensi, + DONumber: context.state.form_receive.number_do, + detail: context.state.form_receive_item + } + + const resp = await api.saveRO(param); + if (resp.status != 'OK') { + context.commit("ro/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, {root: true}); + } else { + context.dispatch("ro/search", {}, {root: true}); + context.dispatch("resetForm"); + + context.commit("ro/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + context.commit("update_dialog_form_receive_item", false); + } + } catch (error) { + context.commit("ro/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, {root: true}); + } + }, + + async saveDataInspeksi(context) { + try { + let param = { + token: one_token(), + ROdetailID: 0, + form_inspeksi: context.state.form_inspeksi + } + + const resp = await api.saveInspeksi(param) + if (resp.status != 'OK') { + context.commit("ro/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, {root: true}); + } else { + context.commit("ro/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + context.commit("update_dialog_form_receive_item", false); + } + } catch (error) { + context.commit("ro/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, {root: true}); + } + }, + + async getDataItemInspeksi(context) { + try { + let param = { + token: one_token(), + ROdetailID: 0, + } + + const resp = await api.getItemDataInspeksi(param) + if (resp.status != 'OK') { + context.commit("ro/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, {root: true}); + } else { + + } + } catch (error) { + context.commit("ro/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, {root: true}); + } + }, + + async confirmRO(context) { + try { + let param = { + token: one_token(), + ROID: context.rootState.ro.selected_ro.ReceiveOrderPoID + } + + const resp = await api.confirmRO(param) + if (resp.status != 'OK') { + context.commit("ro/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, {root: true}); + } else { + context.dispatch("ro/search", {}, {root: true}); + context.dispatch("resetForm"); + + context.commit("ro/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + context.commit("ro/update_dialog_confirmation", false, {root: true}); + } + } catch (error) { + context.commit("ro/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, {root: true}); + } + }, + + async saveEditRO(context) { + try { + const cekShipping = context.state.shipping_info.some(item => item.isUpfront === 'N'); + let param = { + token: one_token(), + ReceiveOrderID: context.rootState.ro.selected_ro.ReceiveOrderPoID, + numGR: context.rootState.ro.selected_ro.ReceiveOrderPoNumber, + date: context.state.form_receive.receive_date, + supplierID: context.state.form_receive.supplier.SupplierID, + warehouseID: context.state.form_receive.warehouse.WarehouseID, + shippingCost: context.state.form_receive.shipping_cost, + shippingIsPaid: cekShipping ? 'N' : 'Y', + note: context.state.form_receive.note, + refNumber: context.state.form_receive.referensi, + DONumber: context.state.form_receive.number_do, + detail: context.state.form_receive_item + } + + const resp = await api.saveEditRO(param) + if (resp.status != 'OK') { + context.commit("ro/update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }, {root: true}); + } else { + context.dispatch("ro/search", {}, {root: true}); + context.dispatch("resetForm"); + + context.commit("ro/update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }, {root: true}); + context.commit("update_dialog_form_receive_item_edit", false); + } + } catch (error) { + context.commit("ro/update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }, {root: true}); + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/modules/ro.js b/test/vuex/acc-one-receive-item-po-v2/modules/ro.js new file mode 100644 index 0000000..6d72247 --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/modules/ro.js @@ -0,0 +1,252 @@ +import * as api from "../api/api.js" + +export default { + namespaced: true, + state: { + dialog_confirmation: false, + dialog_delete: false, + dialog_detail_view: false, + snackbar: { + color: 'success', + msg: '', + isOpen: false + }, + filter: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + search: '' + }, + curr_page: 1, + list_data_ro: { + records: [], + total: 1 + }, + list_supplier: [], + list_warehouse: [], + selected_ro: {}, + list_staff: [] + }, + mutations: { + update_dialog_confirmation(state, data) { + state.dialog_confirmation = data + }, + update_dialog_delete(state, data) { + state.dialog_delete = data + }, + update_dialog_detail_view(state, data) { + state.dialog_detail_view = data + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_filter(state, data) { + state.filter = data + }, + update_curr_page(state, data) { + state.curr_page = data + }, + update_list_data_ro(state, data) { + state.list_data_ro = data + }, + update_list_supplier(state, val) { + state.list_supplier = val + }, + update_list_warehouse(state, val) { + state.list_warehouse = val + }, + update_selected_ro(state, val) { + state.selected_ro = val + }, + update_list_staff(state, val) { + state.list_staff = val + } + }, + actions: { + async search(context) { + try { + let param = { + token: one_token(), + page: context.state.curr_page, + ...context.state.filter + } + + console.log("search OR"); + let resp = await api.search(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("update_list_data_ro", resp.data); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + async getSupplier(context) { + try { + let param = { + token: one_token(), + search: '' + } + const resp = await api.getSupplier(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("update_list_supplier", resp.data); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + async getWarehouse(context) { + try { + let param = { + token: one_token() + } + const resp = await api.getWarehouse(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("update_list_warehouse", resp.data); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + async getItemUpdate(context) { + try { + let param = { + token: one_token(), + ROID: context.state.selected_ro.ReceiveOrderPoID + } + + const resp = await api.getItemUpdate(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + let temp_ship = [] + resp.data.forEach(element => { + let ship = { + num_po: element.PurchaseOrderNumber, + cost: element.PurchaseOrderShippingCost, + isUpfront: element.PurchaseOrderShippingCostStatus + } + + const isExist = context.rootState.form.shipping_info.some( + item => item.num_po == element.PurchaseOrderNumber + ); + if (!isExist) { + temp_ship.push(ship); + } + }); + + let form = { + receive_date: context.state.selected_ro.ReceiveOrderPoIDate, + number_do: context.state.selected_ro.ReceiveOrderPoDONumber, + referensi: context.state.selected_ro.ReceiveOrderPoRefNumber, + supplier: { + SupplierID: context.state.selected_ro.SupplierID, + SupplierName: context.state.selected_ro.SupplierName + }, + warehouse: { + WarehouseID: context.state.selected_ro.WarehouseID, + WarehouseName: context.state.selected_ro.WarehouseName, + WarehouseCode: context.state.selected_ro.WarehouseCode + }, + shipping_cost: context.state.selected_ro.ReceiveOrderShippingCostAmount, + note: context.state.selected_ro.ReceiveOrderPoNote + } + + context.commit("form/update_form_receive", form, {root: true}); + context.commit("form/update_shipping_info", temp_ship, {root: true}); + context.commit("form/update_form_receive_item", resp.data, {root: true}); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + async deleteRO(context) { + try { + let param = { + token: one_token(), + ROID: context.state.selected_ro.ReceiveOrderPoID + } + const resp = await api.deleteRO(param); + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("update_selected_ro", {}); + context.dispatch("search", {}); + + context.commit("update_snackbar", { + color: 'success', + msg: resp.data, + isOpen: true + }); + context.commit("update_dialog_delete", false); + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + }, + async getListStaff(context) { + try { + let resp = await api.getListStaff({token: one_token()}) + if (resp.status != 'OK') { + context.commit("update_snackbar", { + color: 'error', + msg: resp.message, + isOpen: true + }); + } else { + context.commit("update_list_staff", resp.data) + } + } catch (error) { + context.commit("update_snackbar", { + color: 'error', + msg: error.message, + isOpen: true + }); + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-receive-item-po-v2/store.js b/test/vuex/acc-one-receive-item-po-v2/store.js new file mode 100644 index 0000000..b9c2d8f --- /dev/null +++ b/test/vuex/acc-one-receive-item-po-v2/store.js @@ -0,0 +1,23 @@ +import system from "../../../apps/modules/system/system.js"; +import form from "./modules/form.js"; +import ro from "./modules/ro.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + ro: ro, + form: form + }, + state: { + tab_selected: 'pasien-dokter' + }, + mutations: { + change_tab(state, ntab) { + state.tab_selected = ntab + } + }, + actions: { + change_tab(context, ntab) { + context.commit('change_tab', ntab) + } + }, +}); \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/api/api.js b/test/vuex/acc-one-receive-jasa/api/api.js new file mode 100644 index 0000000..62a9ae4 --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/api/api.js @@ -0,0 +1,241 @@ +const URL = "/one-api/mockup/receive-item-po/ReceiveOrderService/"; + +export async function getListingVendor(params) { + try { + var response = await axios.post(URL + "getListingVendor", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListBranch(params) { + try { + var response = await axios.post(URL + "getListBranch", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDaftarStaff(params) { + try { + var response = await axios.post(URL + "getDaftarStaff", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function searchOrderJasa(params) { + try { + var response = await axios.post(URL + "searchOrderJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveReceiveOrderJasa(params) { + try { + var response = await axios.post(URL + "saveReceiveOrderJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListingROJasa(params) { + try { + const response = await axios.post(URL + "getListingROJasa", params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + }; + + const data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function uploadAttachment(params) { + try { + var response = await axios.post(URL + "uploadAttachment", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getListAttachment(params) { + try { + var response = await axios.post(URL + "getListAttachment", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function deleteReceiveOrder(params) { + try { + var response = await axios.post(URL + "deleteReceiveOrder", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getDetailDataROJasa(params) { + try { + var response = await axios.post(URL + "getDetailDataROJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function confirmReceiveOrder(params) { + try { + var response = await axios.post(URL + "confirmReceiveOrder", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function saveEditReceiveOrderJasa(params) { + try { + var response = await axios.post(URL + "editReceiveOrderJasa", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/components/dialog-add-attachment.vue b/test/vuex/acc-one-receive-jasa/components/dialog-add-attachment.vue new file mode 100644 index 0000000..a19ad05 --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/components/dialog-add-attachment.vue @@ -0,0 +1,214 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/components/dialog-add-jasa.vue b/test/vuex/acc-one-receive-jasa/components/dialog-add-jasa.vue new file mode 100644 index 0000000..18a47b0 --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/components/dialog-add-jasa.vue @@ -0,0 +1,251 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/components/dialog-confirm-ro.vue b/test/vuex/acc-one-receive-jasa/components/dialog-confirm-ro.vue new file mode 100644 index 0000000..64e9b6b --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/components/dialog-confirm-ro.vue @@ -0,0 +1,307 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/components/dialog-delete-ro.vue b/test/vuex/acc-one-receive-jasa/components/dialog-delete-ro.vue new file mode 100644 index 0000000..2141f78 --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/components/dialog-delete-ro.vue @@ -0,0 +1,75 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/components/dialog-edit-ro.vue b/test/vuex/acc-one-receive-jasa/components/dialog-edit-ro.vue new file mode 100644 index 0000000..1a38364 --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/components/dialog-edit-ro.vue @@ -0,0 +1,300 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/components/dialog-form-ro.vue b/test/vuex/acc-one-receive-jasa/components/dialog-form-ro.vue new file mode 100644 index 0000000..5a4969e --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/components/dialog-form-ro.vue @@ -0,0 +1,313 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/components/dialog-inspeksi.vue b/test/vuex/acc-one-receive-jasa/components/dialog-inspeksi.vue new file mode 100644 index 0000000..00b82b0 --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/components/dialog-inspeksi.vue @@ -0,0 +1,155 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/components/one-layout.vue b/test/vuex/acc-one-receive-jasa/components/one-layout.vue new file mode 100644 index 0000000..44852d6 --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/components/one-layout.vue @@ -0,0 +1,331 @@ + + + diff --git a/test/vuex/acc-one-receive-jasa/index.php b/test/vuex/acc-one-receive-jasa/index.php new file mode 100644 index 0000000..ccd839e --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/index.php @@ -0,0 +1,60 @@ + + + + + + + + + + One + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/modules/roservice.js b/test/vuex/acc-one-receive-jasa/modules/roservice.js new file mode 100644 index 0000000..ebf8a46 --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/modules/roservice.js @@ -0,0 +1,433 @@ +import * as api from '../api/api.js'; +export default { + namespaced: true, + state: { + /* utility */ + snackbar: { + state: false, + color: 'success', + msg: '' + }, + loading_process: false, + selected_rojasa: {}, + + /* listing received order jasa */ + filterjasa: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + status: "All", + search: "" + }, + liststatus: ['All', 'Confirmed', 'Unconfirmed'], + list_supplier: [], + list_branch: [], + list_rojasa: {}, + currpage_rojasa: 1, + + /* add new receive order jasa */ + dialog_formro: false, + form_rojasa: { + rodate: moment(new Date()).format('YYYY-MM-DD'), + supplierID: 0, + orderjasano: "", + branchcode: one_user()['M_BranchCode'], + reference: "", + typekontrak: "", + startdate: "", + enddate: "", + usedcount: "0 / 0", + catatan: "" + }, + data_rojasa: [], + + dialog_pickjasa: false, + list_pojasa: { + records: [], + total: 0 + }, + + /* upload attachment */ + dialog_attachment: false, + preview_attachment: [], + + /* form inspeksi */ + dialog_inspeksi: false, + list_staff: [], + form_inspeksi: { + hasil_pengerjaan: "good", + catatan_pengerjaan: "", + kesimpulan: "accept", + catatan_kesimpulan: "", + pemeriksa: "", + pekerja: "" + }, + selected_jasainspek: {}, + + /* delete ro */ + dialog_deletero: false, + + /* detail & conform ro */ + dialog_confirm_ro: false, + + /* edit form ro */ + dialog_editro: false + }, + mutations: { + update_snackbar(state, val) { + state.snackbar = val + }, + update_loading_process(state, val) { + state.loading_process = val + }, + update_selected_rojasa(state, val) { + state.selected_rojasa = val + }, + update_filterjasa(state, val) { + state.filterjasa = val + }, + update_liststatus(state, val) { + state.liststatus = val + }, + update_list_supplier(state, val) { + state.list_supplier = val + }, + update_list_branch(state, val) { + state.list_branch = val + }, + update_list_rojasa(state, val) { + state.list_rojasa = val + }, + update_currpage_rojasa(state, val) { + state.currpage_rojasa = val + }, + update_dialog_formro(state, val) { + state.dialog_formro = val + }, + update_form_rojasa(state, val) { + state.form_rojasa = val + }, + update_data_rojasa(state, val) { + state.data_rojasa = val + }, + update_dialog_pickjasa(state, val) { + state.dialog_pickjasa = val + }, + update_list_pojasa(state, val) { + state.list_pojasa = val + }, + update_dialog_attachment(state, val) { + state.dialog_attachment = val + }, + update_preview_attachment(state, val) { + state.preview_attachment = val + }, + update_dialog_inspeksi(state, val) { + state.dialog_inspeksi = val + }, + update_list_staff(state, val) { + state.list_staff = val + }, + update_form_inspeksi(state, val) { + state.form_inspeksi = val + }, + update_selected_jasainspek(state, val) { + state.selected_jasainspek = val + }, + update_dialog_deletero(state, val) { + state.dialog_deletero = val + }, + update_dialog_confirm_ro(state, val) { + state.dialog_confirm_ro = val + }, + update_dialog_editro(state, val) { + state.dialog_editro = val + } + }, + actions: { + async lookupCabang(context) { + try { + const resp = await api.getListBranch({token: one_token()}) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit('update_list_branch', resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupVendor(context) { + try { + const resp = await api.getListingVendor({token: one_token()}) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit('update_list_supplier', resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupStaff(context) { + try { + const resp = await api.getDaftarStaff({token: one_token()}) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit('update_list_staff', resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupOrderJasa(context, keyword) { + try { + let param = { + token: one_token(), + keyword: keyword, + supplierID: context.state.form_rojasa.supplierID, + branchcode: context.state.form_rojasa.branchcode, + // currpage: 1 + } + + const resp = await api.searchOrderJasa(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_list_pojasa", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async saveReceiveOrder(context) { + try { + context.state.loading_process = true + const detail = context.state.data_rojasa + let params = { + ...context.state.form_rojasa, + detail: detail, + token: one_token(), + } + + const resp = await api.saveReceiveOrderJasa(params) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.state.loading_process = false + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + context.dispatch('lookupReceiveOrder') + context.state.dialog_formro = false + } + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async saveEditReceiveOrder(context) { + try { + context.state.loading_process = true + const form = context.state.form_rojasa + const detail = context.state.data_rojasa + let param = { + ...form, + detail: detail, + token: one_token() + } + + const resp = await api.saveEditReceiveOrderJasa(param) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.state.loading_process = false + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + context.dispatch('lookupReceiveOrder') + context.state.selected_rojasa = {} + context.state.data_rojasa = [] + context.state.form_rojasa = {} + context.state.dialog_editro = false + } + + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async uploadAttachment(context, param) { + try { + context.state.loading_process = true + const resp = await api.uploadAttachment(param) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.state.loading_process = false + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + context.dispatch('lookupReceiveOrder') + + context.selected_rojasa = {} + context.state.dialog_attachment = false + } + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupAttachment(context) { + try { + const order = context.state.selected_rojasa + let param = { + token: one_token(), + TJasaID: order.T_KontrakJasaID, + roID: order.ReceiveOrderPoID + } + + const resp = await api.getListAttachment(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_preview_attachment", resp.data); + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupReceiveOrder(context) { + try { + let param = { + token: one_token(), + currpage: context.state.currpage_rojasa, + ...context.state.filterjasa + } + + const resp = await api.getListingROJasa(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_list_rojasa", resp.data) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async deleteReceiveOrder(context) { + try { + context.state.loading_process = true + let order = context.state.selected_rojasa + let param = { + token: one_token(), + roid: order.ReceiveOrderPoID + } + + const resp = await api.deleteReceiveOrder(param) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.state.loading_process = false + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + context.dispatch('lookupReceiveOrder') + + context.selected_rojasa = {} + context.state.dialog_deletero = false + } + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async lookupDetailReceiveOrder(context) { + try { + const order = context.state.selected_rojasa + let param = { + token: one_token(), + roid: order.ReceiveOrderPoID + } + + const resp = await api.getDetailDataROJasa(param) + if (resp.status != 'OK') { + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.commit("update_form_rojasa", resp.data.header) + context.commit("update_data_rojasa", resp.data.detail) + } + } catch (error) { + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + + async confirmReceiveOrder(context) { + try { + context.state.loading_process = true + const formro = context.state.form_rojasa + let param = { + token: one_token(), + roid: formro.ReceiveOrderPoID, + TJasaID: formro.TJasaID + } + + const resp = await api.confirmReceiveOrder(param) + if (resp.status != 'OK') { + context.state.loading_process = false + let snac = {color: 'error', msg: resp.message, state: true} + context.commit('update_snackbar', snac) + } else { + context.state.loading_process = false + let snac = {color: 'success', msg: resp.data, state: true} + context.commit('update_snackbar', snac) + + context.dispatch('lookupReceiveOrder') + context.state.data_rojasa = [] + context.state.selected_rojasa = {} + context.state.dialog_confirm_ro = false + } + } catch (error) { + context.state.loading_process = false + let snac = {color: 'error', msg: error.message, state: true} + context.commit('update_snackbar', snac) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-receive-jasa/store.js b/test/vuex/acc-one-receive-jasa/store.js new file mode 100644 index 0000000..fc0d8eb --- /dev/null +++ b/test/vuex/acc-one-receive-jasa/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js"; +import roservice from "./modules/roservice.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + roservice: roservice + }, + state: {}, + mutations: {}, + actions: {} +}); \ No newline at end of file diff --git a/test/vuex/acc-one-receive-order-asset/api/api.js b/test/vuex/acc-one-receive-order-asset/api/api.js new file mode 100644 index 0000000..e69de29 diff --git a/test/vuex/acc-one-receive-order-asset/components/main-layout.vue b/test/vuex/acc-one-receive-order-asset/components/main-layout.vue new file mode 100644 index 0000000..bc392ed --- /dev/null +++ b/test/vuex/acc-one-receive-order-asset/components/main-layout.vue @@ -0,0 +1,148 @@ + + + diff --git a/test/vuex/acc-one-receive-order-asset/index.php b/test/vuex/acc-one-receive-order-asset/index.php new file mode 100644 index 0000000..2885b6f --- /dev/null +++ b/test/vuex/acc-one-receive-order-asset/index.php @@ -0,0 +1,59 @@ + + + + + + + + + + One + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/test/vuex/acc-one-receive-order-asset/modules/roasset.js b/test/vuex/acc-one-receive-order-asset/modules/roasset.js new file mode 100644 index 0000000..6813dcb --- /dev/null +++ b/test/vuex/acc-one-receive-order-asset/modules/roasset.js @@ -0,0 +1,51 @@ +import * as api from "../api/api.js"; +export default { + namespaced: true, + state: { + /* common */ + snackbar: { + color: 'success', + msg: '', + state: false + }, + loading_process: false, + + /* main layout */ + filterasset: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + status: 'All', + search: '' + }, + list_status: ['All', 'Confirmed', 'Unconfirmed'], + list_roasset: { + records: [], + total: 0 + }, + currpage: 1 + }, + mutations: { + /* common */ + update_snackbar(state, val) { + state.snackbar = val + }, + update_loading_process(state, val) { + state.loading_process = val + }, + + /* main layout */ + update_filterasset(state, val) { + state.filterasset = val + }, + update_list_status(state, val) { + state.list_status = val + }, + update_list_roasset(state, val) { + state.list_roasset = val + }, + update_currpage(state, val) { + state.currpage = val + } + }, + actions: {} +} diff --git a/test/vuex/acc-one-receive-order-asset/store.js b/test/vuex/acc-one-receive-order-asset/store.js new file mode 100644 index 0000000..c30f9c5 --- /dev/null +++ b/test/vuex/acc-one-receive-order-asset/store.js @@ -0,0 +1,12 @@ +import system from "../../../apps/modules/system/system.js"; +import roasset from "./modules/roasset.js" + +export const store = new Vuex.Store({ + modules: { + system: system, + roasset:roasset + }, + state: {}, + mutatios: {}, + actions: {} +}); diff --git a/test/vuex/acc-one-receive-surat-jalan/api/api.js b/test/vuex/acc-one-receive-surat-jalan/api/api.js new file mode 100644 index 0000000..a7cdaf6 --- /dev/null +++ b/test/vuex/acc-one-receive-surat-jalan/api/api.js @@ -0,0 +1,156 @@ +const URL = "/one-api/mockup/purchase/receivesuratjalan/ReceiveSuratJalan/"; + +export async function lookupEkpedisi(params) { + try { + var response = await axios.post(URL + 'LookupEkspedisi', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} +export async function lookupEkspedisiStaff(params) { + try { + var response = await axios.post(URL + 'LookupEkspedisiStaff', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} +export async function listingBranch(params) { + try { + var response = await axios.post(URL + 'ListingBranch', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} +export async function lookupWarehouse(params) { + try { + var response = await axios.post(URL + 'LookupWarehouse', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} +export async function lookupDetailSuratJalan(params) { + try { + var response = await axios.post(URL + 'LookupDetailSuratJalan', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} +export async function lookupSuratJalan(params) { + try { + var response = await axios.post(URL + 'LookupSuratJalan', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} +export async function saveReciveSJ(params) { + try { + var response = await axios.post(URL + 'SaveReceiveSJ', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +// test input +export async function testinput(params) { + try { + var response = await axios.post(URL + 'TestInput', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-receive-surat-jalan/components/dialogreceive.vue b/test/vuex/acc-one-receive-surat-jalan/components/dialogreceive.vue new file mode 100644 index 0000000..5673797 --- /dev/null +++ b/test/vuex/acc-one-receive-surat-jalan/components/dialogreceive.vue @@ -0,0 +1,130 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-surat-jalan/components/form.vue b/test/vuex/acc-one-receive-surat-jalan/components/form.vue new file mode 100644 index 0000000..de8fb51 --- /dev/null +++ b/test/vuex/acc-one-receive-surat-jalan/components/form.vue @@ -0,0 +1,277 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-surat-jalan/components/listing.vue b/test/vuex/acc-one-receive-surat-jalan/components/listing.vue new file mode 100644 index 0000000..5c3c237 --- /dev/null +++ b/test/vuex/acc-one-receive-surat-jalan/components/listing.vue @@ -0,0 +1,238 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-surat-jalan/index.php b/test/vuex/acc-one-receive-surat-jalan/index.php new file mode 100644 index 0000000..991f0a4 --- /dev/null +++ b/test/vuex/acc-one-receive-surat-jalan/index.php @@ -0,0 +1,70 @@ + + + + + + + + + + + ACCONE | RECEIVE SURAT JALAN + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-receive-surat-jalan/modules/suratjalan.js b/test/vuex/acc-one-receive-surat-jalan/modules/suratjalan.js new file mode 100644 index 0000000..0a7a889 --- /dev/null +++ b/test/vuex/acc-one-receive-surat-jalan/modules/suratjalan.js @@ -0,0 +1,346 @@ +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + f_startdate: new Date().toISOString().substr(0, 10), + f_enddate: new Date().toISOString().substr(0, 10), + f_cabang: {"M_BranchCode":"ALL","M_BranchName":"SEMUA"}, + f_status: "All", + f_search: "", + + l_suratjalan: [], + l_total_page: 0, + l_cabang: [], + l_status: ["All", "Draft", "Process", "Completed"], + paginat: 1, + + l_ekspedisi: [], + l_staff: [], + l_tfrequest: [], + l_warehouse: [], + + + s_suratjalan: { + SuratJalanID: 0, + SuratJalanNumber: "", + i_tftype: "", + i_tfrequest: {}, + i_isInternal: "", + i_ekspedisi: {}, + i_staff: {}, + i_phone: "", + i_notes: "", + i_status: "", + i_date: new Date().toISOString().substr(0, 10), + i_receivewarehouse: {}, + i_receivenotes: "", + i_isConfirmed: "N", + detail: [] + }, + d_page: 1, + dialog_receive: false, + receive_items: [], + buffer_item: {}, + + snackbar: { + isOpen: false, + color: "error", + message: "" + } + }, + mutations: { + update_f_startdate(state, data) { + state.f_startdate = data + }, + update_f_enddate(state, data) { + state.f_enddate = data + }, + update_f_cabang(state, data) { + state.f_cabang = data + }, + update_f_status(state, data) { + state.f_status = data + }, + update_f_search(state, data) { + state.f_search = data + }, + update_l_suratjalan(state, data) { + state.l_suratjalan = data + }, + update_l_total_page(state, data) { + state.l_total_page = data + }, + update_paginat(state, data) { + state.paginat = data + }, + update_l_cabang(state, data) { + state.l_cabang = data + }, + update_l_ekspedisi(state, data) { + state.l_ekspedisi = data + }, + update_l_staff(state, data) { + state.l_staff = data + }, + update_l_tfrequest(state, data) { + state.l_tfrequest = data + }, + update_l_warehouse(state, data) { + state.l_warehouse = data + }, + update_s_suratjalan(state, data) { + state.s_suratjalan = data + }, + update_dialog_receive(state, data) { + state.dialog_receive = data + }, + update_receive_items(state, data) { + state.receive_items = data + }, + update_buffer_item(state, data) { + state.buffer_item = data + }, + update_d_page(state, data) { + state.d_page = data + }, + update_snackbar(state, data) { + state.snackbar = data + } + }, + actions: { + async newForm(context) { + let form = { + SuratJalanID: 0, + SuratJalanNumber: "", + i_tftype: "", + i_tfrequest: {}, + i_isInternal: "", + i_ekspedisi: {}, + i_staff: {}, + i_phone: "", + i_notes: "", + i_status: "", + i_date: new Date().toISOString().substr(0, 10), + i_receivewarehouse: {}, + i_receivenotes: "", + i_isConfirmed: "N", + detail: [] + } + context.commit("update_s_suratjalan", form) + }, + async LookupBranches(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID + } + + const resp = await api.listingBranch(params) + if (resp.status != 'OK') { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", sn) + } else { + let data = resp.data.records + let all = { + M_BranchCode: "ALL", + M_BranchName: "SEMUA" + } + + if (context.state.user.M_BranchCode == '') { + data.unshift(all) + } + + if (context.state.user.M_BranchCode != '') { + context.commit("update_f_cabang", data[0]) + } + + await context.commit("update_l_cabang", data) + await context.dispatch("LookupSuratJalan") + } + } catch (error) { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", sn) + } + }, + async LookupEkpedisi(context) { + try { + let params = { + token: one_token(), + expdName: "", + isInternal: context.state.s_suratjalan.i_isInternal === 'Internal' ? 'Y' : 'N' + } + const resp = await api.lookupEkpedisi(params) + if (resp.status != 'OK') { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", sn) + } else { + context.commit("update_l_ekspedisi", resp.data.records) + } + } catch (error) { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", sn) + } + }, + async LookupEkspedisiStaff(context) { + try { + let params = { + token: one_token(), + staffName: "", + expID: context.state.s_suratjalan.i_ekspedisi.ExpeditionID + } + + const resp = await api.lookupEkspedisiStaff(params) + if (resp.status != 'OK') { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", sn) + } else { + context.commit("update_l_staff", resp.data.records) + } + } catch (error) { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", sn) + } + }, + async LookupWarehouse(context) { + try { + let params = { + token: one_token() + } + const resp = await api.lookupWarehouse(params) + if (resp.status != 'OK') { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", sn) + } else { + context.commit("update_l_warehouse", resp.data) + } + } catch (error) { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", sn) + } + }, + async LookupSuratJalan(context) { + try { + let params = { + token: one_token(), + startdate: context.state.f_startdate, + enddate: context.state.f_enddate, + branchcode: context.state.f_cabang.M_BranchCode, + status: context.state.f_status, + search: context.state.f_search, + currpage: context.state.paginat + } + + const resp = await api.lookupSuratJalan(params) + if (resp.status != 'OK') { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", sn) + } else { + context.commit("update_l_suratjalan", resp.data.records) + context.commit("update_l_total_page", resp.data.total) + } + } catch (error) { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", sn) + } + }, + async LookupDetailSuratJalan(context, payload) { + try { + let params = { + token: one_token(), + SuratJalanID: payload.id + } + + const resp = await api.lookupDetailSuratJalan(params) + if (resp.status != 'OK') { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", sn) + } else { + const data = resp.data.records + let sj = context.state.s_suratjalan + + sj.SuratJalanID = data.SuratJalanID + sj.SuratJalanNumber = data.SuratJalanNumber + sj.i_tftype = data.T_GoodsTransferType == 'P' ? 'Persediaan' : 'Non Persediaan' + sj.i_status = data.SuratJalanStatus + sj.i_notes = data.SuratJalanNote + sj.i_phone = data.ExpeditionStaffMobile + sj.i_date = data.SuratJalanDate + sj.i_receivenotes = data.SuratJalanReceivedNote + sj.i_isConfirmed = data.SuratJalanReceivedConfirmed + sj.detail = data.detail + + sj.i_tftype = data.T_GoodsTransferType == 'P' ? 'Persediaan' : 'Non Persediaan' + sj.i_isInternal = data.ExpeditionIsInternal == 'Y' ? 'Internal' : 'Eksternal' + + let ekspedisi = { + ExpeditionID: data.ExpeditionID, + ExpeditionIsInternal: data.ExpeditionIsInternal, + ExpeditionName: data.ExpeditionName + } + sj.i_ekspedisi = ekspedisi + + let staff = { + ExpeditionStaffID: data.SuratJalanEkspedisiStaffID, + ExpeditionStaffMobile: data.ExpeditionStaffMobile, + ExpeditionStaffName: data.ExpeditionStaffName + } + sj.i_staff = staff + + let tfreq = { + T_GoodsTransferID: data.T_GoodsTransferID, + T_GoodsTransferNum: data.T_GoodsTransferNum, + T_GoodsTransferType: data.T_GoodsTransferType, + T_GoodsTransferDate: data.T_GoodsTransferDate + } + sj.i_tfrequest = tfreq + + let wh = context.state.l_warehouse.find(obj => obj.WarehouseID == data.SuratJalanReceivedWarehouseID) + sj.i_receivewarehouse = wh + + await context.commit("update_l_tfrequest", [tfreq]) + await context.commit("update_s_suratjalan", sj) + await context.dispatch("LookupEkpedisi") + await context.dispatch("LookupEkspedisiStaff") + } + } catch (error) { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", sn) + } + }, + async saveReceveiSJ(context) { + try { + const sj = context.state.s_suratjalan + let params = { + token: one_token(), + ...sj + } + const resp = await api.saveReciveSJ(params) + if (resp.status != 'OK') { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", sn) + } else { + context.dispatch("newForm") + context.dispatch("LookupSuratJalan") + + let sn = { isOpen: true, color: "success", msg: "Success, simpan receive surat jalan" } + context.commit("update_snackbar", sn) + } + } catch (error) { + let sn = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", sn) + } + }, + + async testinput(context) { + const sj = context.state.s_suratjalan + let params = { + token: one_token(), + ...sj + } + const resp = await api.testinput(params) + console.log(resp.data) + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-receive-surat-jalan/store.js b/test/vuex/acc-one-receive-surat-jalan/store.js new file mode 100644 index 0000000..aff8436 --- /dev/null +++ b/test/vuex/acc-one-receive-surat-jalan/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js" +import suratjalan from "./modules/suratjalan.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + suratjalan: suratjalan + }, + state: {}, + mutations: {}, + actions: {} +}); \ No newline at end of file diff --git a/test/vuex/acc-one-request-item-out/api/api.js b/test/vuex/acc-one-request-item-out/api/api.js new file mode 100644 index 0000000..d58d30f --- /dev/null +++ b/test/vuex/acc-one-request-item-out/api/api.js @@ -0,0 +1,438 @@ +const URL = "/one-api/mockup/itemout/"; + +export async function search(payload) { + try { + var response = await axios.post(URL + "RequestItemOut/search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchDetail(payload) { + try { + var response = await axios.post( + URL + "RequestItemOut/searchDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getRegional(payload) { + try { + var response = await axios.post(URL + "RequestItemOut/getRegionalBranchByUser", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getBranch(payload) { + try { + var response = await axios.post(URL + "RequestItemOut/getBranch", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteRequest(payload) { + try { + var response = await axios.post( + URL + "RequestItemOut/deleteRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function saveDetail(payload) { + try { + var response = await axios.post( + URL + "RequestItemOut/saveDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateDetail(payload) { + try { + var response = await axios.post( + URL + "RequestItemOut/updateDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function deleteDetail(payload) { + try { + var response = await axios.post( + URL + "RequestItemOut/deleteDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function orderRequest(payload) { + try { + var response = await axios.post( + URL + "RequestItemOut/orderRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getUnit(token, prm) { + try { + var resp = await axios.post(URL + 'RequestItemOut/getUnit', { + token: token, + search: prm + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function getDivisionByUser(payload) { + try { + var resp = await axios.post(URL + 'RequestItemOut/getDivisionByUser', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function getItems(payload) { + try { + var resp = await axios.post(URL + 'RequestItemOut/getItems', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getItemGroupSubGroup(payload) { + try { + var resp = await axios.post(URL + 'RequestItemOut/getItemGroupSubGroup', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getUnitByItemId(payload) { + try { + var resp = await axios.post(URL + 'RequestItemOut/getUnitByItemId', payload); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveRequest(payload) { + try { + var response = await axios.post(URL + 'RequestItemOut/saveRequest', payload); + if (response.status != 200) { + return { + status: "ERR", + message: response.statusText + }; + } + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getAPI(fn,payload) { + try { + let urx = URL + 'RequestItemOut/'+fn; + console.log(urx); + var response = await axios.post(urx, payload); + if (response.status != 200) { + return { + status: "ERR", + message: response.statusText + }; + } + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getWarehouse(payload) { + try { + var response = await axios.post( + URL + "RequestItemOut/getWarehouse", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getlevel(payload) { + try { + var response = await axios.post(URL + "RequestItemOut/getlevel", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function getDivisionUser(payload) { + try { + var response = await axios.post(URL + "RequestItemOut/getDivisionUser", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approveRequest(payload) { + try { + var response = await axios.post(URL + 'RequestItemOut/approveRequest', payload); + if (response.status != 200) { + return { + status: "ERR", + message: response.statusText + }; + } + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function rejectRequest(payload) { + try { + var response = await axios.post(URL + 'RequestItemOut/rejectRequest', payload); + if (response.status != 200) { + return { + status: "ERR", + message: response.statusText + }; + } + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-request-item-out/components/addRequestDetailDialog.vue b/test/vuex/acc-one-request-item-out/components/addRequestDetailDialog.vue new file mode 100644 index 0000000..60936d0 --- /dev/null +++ b/test/vuex/acc-one-request-item-out/components/addRequestDetailDialog.vue @@ -0,0 +1,280 @@ + + + diff --git a/test/vuex/acc-one-request-item-out/components/addRequestDialog.vue b/test/vuex/acc-one-request-item-out/components/addRequestDialog.vue new file mode 100644 index 0000000..6e20088 --- /dev/null +++ b/test/vuex/acc-one-request-item-out/components/addRequestDialog.vue @@ -0,0 +1,925 @@ + + + diff --git a/test/vuex/acc-one-request-item-out/components/approveDialog.vue b/test/vuex/acc-one-request-item-out/components/approveDialog.vue new file mode 100644 index 0000000..1d109d9 --- /dev/null +++ b/test/vuex/acc-one-request-item-out/components/approveDialog.vue @@ -0,0 +1,859 @@ + + + diff --git a/test/vuex/acc-one-request-item-out/components/requestListing.vue b/test/vuex/acc-one-request-item-out/components/requestListing.vue new file mode 100644 index 0000000..736de45 --- /dev/null +++ b/test/vuex/acc-one-request-item-out/components/requestListing.vue @@ -0,0 +1,912 @@ + + + + + diff --git a/test/vuex/acc-one-request-item-out/index.php b/test/vuex/acc-one-request-item-out/index.php new file mode 100644 index 0000000..06e67ec --- /dev/null +++ b/test/vuex/acc-one-request-item-out/index.php @@ -0,0 +1,118 @@ + + + + + + + + + + + One + + + + + + + + + Error + + + + {{errMessage}} + + + + + + + + Tutup + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-request-item-out/modules/requester.js b/test/vuex/acc-one-request-item-out/modules/requester.js new file mode 100644 index 0000000..ad245c7 --- /dev/null +++ b/test/vuex/acc-one-request-item-out/modules/requester.js @@ -0,0 +1,1055 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + mainTable: [], + detailTable: [], + countMainTable: 0, + countDetailTable: 0, + mainTableLoadingStatus: 0, + detailTableLoadingStatus: 0, + mainTableErrorMessage: "", + detailTableErrorMessage: "", + mainTableCurrentPage: 1, + mainTableLastId: -1, + + selectedMainTable: {}, + selectedDetailTable: {}, + + statusOptions: [ + { value: '', title: "All" }, + { value: 'Draft', title: "Draft" }, + { value: 'Send Request', title: "Send Request" }, + { value: 'Process', title: "Process" }, + { value: 'Rejected', title: "Rejected" }, + { value: 'Partial', title: "Partial" }, + { value: 'Completed', title: "Completed" }, + ], + branchOptions: [], + regionalOptions: [], + + menuStartDate: false, + menuEndDate: false, + menuDateUse: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + fStatus: '', + fSearch: "", + + dDateUse: new Date().toISOString().substring(0, 10), + xDateUse: moment(new Date()).format("YYYY-MM-DD"), + xRegional: "", + xBranch: "", + xDescription: "", + xPRID: 0, + xNumber: "", + xPRDID: 0, + xDescriptionDetail: "", + xAmountRequest: 0, + xEstimationPrice: 0, + + dialogRequest: false, + dialogDetail: false, + act: "new", + errMessage: "", + succesMessage: "", + alertError: false, + alertSuccess: false, + errors: [], + total_price: 0, + item_units: [], + selected_item_unit: {}, + search_item_unit: "", + loadingAutocomplete: false, + divisionOptions: [], + selectedDivision: {}, + itemCurrentPage: 1, + itemTotalPage: 0, + itemLastId: -1, + items: [], + selectedItems: [], + selectedItem: {}, + searchItem: "", + itemCurrentPage: 1, + itemTotalPage: 0, + loadingItem: false, + itemGroupOptions: [], + selectedItemGroup: {}, + loadingItemGroup: false, + itemSubGroupOptions: [], + selectedItemSubGroup: {}, + loadingItemSubGroup: false, + dialogUnit: false, + selectedUnit: {}, + unitOptions: [], + loadingUnit: false, + loadingSave: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + loadingDetailRequest: false, + warehouseOptions: [], + selectedWarehouse: {}, + user: one_user(), + dialogItem: false, + dialogApprove: false, + act_approve: "approve", + levelname: [], + loadingSaveRequest: false, + approveLevelID: 0, + approveDivision: '', + approveDivisionUserID: 0, + categoryApprove: '', + emptycheckvalue: [], + flag: '' + }, + mutations: { + updateLoadingDetailRequest(state, val) { + state.loadingDetailRequest = val; + }, + updateSnackbar(state, val) { + state.snackbar = val; + }, + updateSelectedItem(state, val) { + state.selectedItem = val; + }, + updateLoadingSave(state, val) { + state.loadingSave = val; + }, + updateLoadingUnit(state, val) { + state.loadingUnit = val; + }, + updateDialogUnit(state, val) { + state.dialogUnit = val; + }, + updateSelectedUnit(state, val) { + state.selectedUnit = val; + }, + updateUnitOptions(state, val) { + state.unitOptions = val; + }, + updateItemCurrentPage(state, val) { + state.itemCurrentPage = val; + }, + updateItemTotalPage(state, val) { + state.itemTotalPage = val; + }, + updateItemLastId(state, val) { + state.itemLastId = val; + }, + updateDivisionOptions(state, val) { + state.divisionOptions = val; + }, + updateSelectedDivision(state, val) { + state.selectedDivision = val; + }, + updateMainTable(state, val) { + state.mainTable = val; + }, + updateDetailTable(state, val) { + state.detailTable = val; + }, + updateCountMainTable(state, val) { + state.countMainTable = val; + }, + updateCountDetailTable(state, val) { + state.countDetailTable = val; + }, + updateMainTableLoadingStatus(state, val) { + state.mainTableLoadingStatus = val; + }, + updateDetailTableLoadingStatus(state, val) { + state.detailTableLoadingStatus = val; + }, + updateMainTableErrorMessage(state, val) { + state.mainTableErrorMessage = val; + }, + updateDetailTableErrorMessage(state, val) { + state.detailTableErrorMessage = val; + }, + updateMainTableCurrentPage(state, val) { + state.mainTableCurrentPage = val; + }, + updateMainTableLastId(state, val) { + state.mainTableLastId = val; + }, + + updateSelectedMainTable(state, val) { + state.selectedMainTable = val; + }, + updateSelectedDetailTable(state, val) { + state.selectedDetailTable = val; + }, + + updateBranchOptions(state, val) { + state.branchOptions = val; + }, + + updateRegionalOptions(state, val) { + state.regionalOptions = val; + }, + + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + updateMenuDateUse(state, val) { + state.menuDateUse = val; + }, + + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateFStatus(state, val) { + state.fStatus = val; + }, + updateFSearch(state, val) { + state.fSearch = val; + }, + + updateDDateUse(state, val) { + state.dDateUse = val; + }, + updateXDateUse(state, val) { + state.xDateUse = val; + }, + updateXRegional(state, val) { + state.xRegional = val; + }, + updateXBranch(state, val) { + state.xBranch = val; + }, + updateXDescription(state, val) { + state.xDescription = val; + }, + updateXPRID(state, val) { + state.xPRID = val; + }, + updateXNumber(state, val) { + state.xNumber = val; + }, + updateXPRDID(state, val) { + state.xPRDID = val; + }, + updateXDescriptionDetail(state, val) { + state.xDescriptionDetail = val; + }, + updateXAmountRequest(state, val) { + state.xAmountRequest = val; + }, + updateXEstimationPrice(state, val) { + state.xEstimationPrice = val; + }, + + updateDialogRequest(state, val) { + state.dialogRequest = val; + }, + updateDialogDetail(state, val) { + state.dialogDetail = val; + }, + updateAct(state, val) { + state.act = val; + }, + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateSuccessMessage(state, val) { + state.successMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateAlertSuccess(state, val) { + state.alertSuccess = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + updateTotalPrice(state, val) { + state.total_price = val; + }, + updateItemUnits(state, val) { + state.item_units = val; + }, + updateSelectedItemUnit(state, val) { + state.selected_item_unit = val; + }, + updateSearchItemUnit(state, val) { + state.search_item_unit = val; + }, + updateLoadingAutocomplete(state, val) { + state.loadingAutocomplete = val; + }, + updateItems(state, val) { + state.items = val; + }, + updateSelectedItems(state, val) { + state.selectedItems = val; + }, + updateSearchItem(state, val) { + state.searchItem = val; + }, + updateLoadingItem(state, val) { + state.loadingItem = val; + }, + updateItemGroupOptions(state, val) { + state.itemGroupOptions = val; + }, + updateSelectedItemGroup(state, val) { + state.selectedItemGroup = val; + }, + updateItemSubGroupOptions(state, val) { + state.itemSubGroupOptions = val; + }, + updateSelectedItemSubGroup(state, val) { + state.selectedItemSubGroup = val; + }, + updateLoadingItemGroup(state, val) { + state.loadingItemGroup = val; + }, + updateLoadingItemSubGroup(state, val) { + state.loadingItemSubGroup = val; + }, + updateWarehouseOptions(state, val) { + state.warehouseOptions = val + }, + updateSelectedWarehouse(state, val) { + state.selectedWarehouse = val + }, + updateUser(state, val) { + state.user = val + }, + updateDialogItem(state, val) { + state.dialogItem = val + }, + update_dialogApprove(state, val) { + state.dialogApprove = val + }, + update_act_approve(state, val) { + state.act_approve = val + }, + updateLevelName(state, val) { + state.levelname = val; + }, + updateLoadingSaveRequest(state, val) { + state.loadingSaveRequest = val; + }, + updateApproveLevelID(state, val) { + state.approveLevelID = val; + }, + updateApproveDivision(state, val) { + state.approveDivision = val; + }, + updateApproveDivisionUserID(state, val) { + state.approveDivisionUserID = val; + }, + updateCategoryApprove(state, val) { + state.categoryApprove = val; + }, + updateEmptycheckvalue(state, val) { + state.emptycheckvalue = val + }, + update_flag(state, val) { + state.flag = val + } + }, + actions: { + async search(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var url_string = window.location.href + var url = new URL(url_string); + var status = url.searchParams.get("status"); + var xstartdate = url.searchParams.get("startdate"); + var xsearch = url.searchParams.get("search"); + var xflag = url.searchParams.get("flag"); + + if (status === 'SendRequest') { + status = 'Send Request'; + } + + // untuk notifikasi + if (xflag == 'N') { + + if (xsearch != null && xsearch != '') { + context.commit("updateFSearch", xsearch); + } + if (status != null && status != '') { + context.commit("updateFStatus", status); + } + if (xstartdate != null && xstartdate != '') { + context.commit("updateFStartDate", xstartdate); + context.commit("updateFEndDate", xstartdate); + } + + } else if (xflag == 'G') { + // untuk get data param approve all + + if (status != null && status != '') { + context.commit("updateFStatus", status); + } + if (xstartdate != null && xstartdate != '') { + context.commit("updateFStartDate", xstartdate); + context.commit("updateFEndDate", moment(new Date()).format('YYYY-MM-DD')); + } + context.commit("update_flag", xflag); + + } + + var payload = { + token: one_token(), + currentPage: context.state.mainTableCurrentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus, + search: context.state.fSearch, + flag: context.state.flag, + lastId: -1, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateMainTable", data.records); + context.commit("updateCountMainTable", data.total); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async searchDetail(context) { + context.commit("updateDetailTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + PRID: context.state.selectedMainTable.PurchaseRequestID, + }; + + let response = await api.searchDetail(payload); + if (response.status != "OK") { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", response.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("updateDetailTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateDetailTable", data.records); + context.commit("updateCountDetailTable", data.total); + } + } catch (e) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", e.message); + } + }, + async regional(context) { + let response = await api.getRegional({ token: one_token() }); + if (response.status === "OK") { + let data = { + records: response.data.records, + }; + + context.commit("updateRegionalOptions", data.records); + } + }, + async branch(context) { + let response = await api.getBranch({ token: one_token() }); + if (response.status === "OK") { + let data = { + records: response.data.records, + }; + + context.commit("updateBranchOptions", data.records); + } + }, + + async deleteRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogRequest", false); + var msg = `Request dengan kode ${payload.RIONumber} berhasil dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async saveDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.saveDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request baru ${payload.PRDDescription} sudah tersimpan`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = "Perubahan Request sudah tersimpan"; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request [${payload.PRDDescriptionDetail}] sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async orderRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.orderRequest(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getUnit(context, prm) { + context.commit("updateLoadingAutocomplete", true) + try { + let resp = await api.getUnit(one_token(), prm) + if (resp.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", ""); + let data = { + records: resp.data.records + } + + context.commit("updateItemUnits", data.records) + } + } catch (e) { + context.commit("updateLoadingAutocomplete", true) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getDivisionByUser(context, payload) { + context.commit("updateLoadingAutocomplete", true) + try { + payload.token = one_token() + payload.userId = context.state.user.M_UserID + let response = await api.getDivisionByUser(payload); + if (response.status != "OK") { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingAutocomplete", false) + let data = { + records: response.data.records, + selected: response.data.selected + }; + context.commit("updateErrMessage", "cek divison"); + context.commit("updateDivisionOptions", data.records); + context.commit("updateSelectedDivision", data.selected[0]); + // context.dispatch("getItemGroupSubGroup",data.selected[0]); + } + } catch (e) { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getItemGroupSubGroup(context) { + context.commit("updateLoadingItemGroup", true) + context.commit("updateLoadingItemSubGroup", true) + try { + let response = await api.getItemGroupSubGroup({ token: one_token(), division: context.state.selectedDivision.DivisionID }); + if (response.status != "OK") { + context.commit("updateLoadingItemGroup", false) + context.commit("updateLoadingItemSubGroup", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItemGroup", false) + context.commit("updateLoadingItemSubGroup", false) + context.commit("updateErrMessage", "item group"); + context.commit("updateItemGroupOptions", response.data.records); + context.commit("updateSelectedItemGroup", response.data.records[0]); + context.commit("updateItemSubGroupOptions", response.data.records[0].subGroups); + context.commit("updateSelectedItemSubGroup", response.data.records[0].subGroups[0]); + + } + } catch (e) { + context.commit("updateLoadingItemGroup", false) + context.commit("updateLoadingItemSubGroup", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getItems(context, payload) { + context.commit("updateLoadingItem", true) + try { + payload.token = one_token(); + payload.currentPage = context.state.itemCurrentPage; + let response = await api.getItems(payload); + if (response.status != "OK") { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", "cekkk"); + context.commit("updateItems", response.data.records); + context.commit("updateItemTotalPage", response.data.total); + // if(!isEmpty(context.state.selectedMainTable)) { + // context.dispatch("getSelectedItem", context.state.selectedMainTable); + // } + } + } catch (e) { + context.commit("updateLoadingItem", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getSelectedItem(context, payload) { + try { + payload.token = one_token(); + let response = await api.getSelectedItem(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + context.commit("updateSelectedItem", response.data.records); + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getUnitByItemId(context, payload) { + context.commit("updateLoadingUnit", true) + context.commit("updateDialogUnit", true); + try { + payload.token = one_token(); + let response = await api.getUnitByItemId(payload); + if (response.status != "OK") { + context.commit("updateLoadingUnit", false) + context.commit("updateDialogUnit", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingUnit", false) + context.commit("updateErrMessage", ""); + context.commit("updateUnitOptions", response.data.records); + context.commit("updateSelectedUnit", payload.selectedUnit); + + } + } catch (e) { + context.commit("updateLoadingUnit", false) + context.commit("updateDialogUnit", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getGroupByDivision(context, payload) { + context.commit("updateLoadingItemGroup", true) + try { + let response = await api.getGroupByDivision(payload); + if (response.status != "OK") { + context.commit("updateLoadingItemGroup", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingItemGroup", false) + context.commit("updateErrMessage", ""); + context.commit("updateItemGroupOptions", response.data.records); + context.commit("updateSelectedItemGroup", response.data.records[0]); + } + } catch (e) { + context.commit("updateLoadingItemGroup", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async saveRequest(context, payload) { + context.commit("updateLoadingSave", true); + try { + payload.token = one_token(); + let response = await api.saveRequest(payload); + if (response.status != "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateDialogRequest", false); + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Request pengeluaran barang berhasil disimpan', + }); + console.log(context.state.snackbar); + context.commit("updateSelectedItems", []); + context.commit("updateSelectedItem", {}); + context.commit("updateItems", []); + context.commit("updateItemTotalPage", 0); + context.commit("updateItemCurrentPage", 1); + context.commit("updateItemLastId", -1); + context.dispatch("search"); + } + + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async getDetailRequest(context, payload) { + context.commit("updateLoadingDetailRequest", true) + try { + payload.token = one_token(); + let response = await api.getAPI('getDetailRequest',payload); + if (response.status != "OK") { + context.commit("updateLoadingDetailRequest", false) + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateSelectedItems", response.data.records); + context.commit("updateLoadingDetailRequest", false) + } + } catch (e) { + context.commit("updateLoadingDetailRequest", false) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async updateRequest(context, payload) { + context.commit("updateLoadingSave", true); + try { + payload.token = one_token(); + let response = await api.getAPI('updateRequest',payload); + if (response.status != "OK") { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSave", false); + context.commit("updateDialogRequest", false); + if (payload.act == 'sendrequest') { + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Send Request '+payload.RIONumber+' berhasil', + }); + } else { + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Request '+payload.RIONumber+' berhasil diupdate', + }); + } + + context.commit("updateSelectedItems", []); + context.commit("updateSelectedItem", {}); + context.commit("updateItems", []); + context.commit("updateItemLastId", -1); + context.dispatch("search"); + } + + } catch (e) { + context.commit("updateLoadingSave", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getWarehouse(context) { + context.commit("updateLoadingAutocomplete", true) + try { + let prm = {} + prm.regionalId = context.state.user.S_RegionalID + prm.branchCode = context.state.user.M_BranchCode + prm.token = one_token() + let response = await api.getWarehouse(prm); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + context.commit("updateLoadingAutocomplete", false) + } else { + context.commit("updateLoadingAutocomplete", false) + context.commit("updateErrMessage", "cekk warehouse"); + let data = { + records: response.data.records, + }; + + // context.commit("updateWarehouseOptions", data.records); + context.commit("updateSelectedWarehouse", data.records); + } + } catch (e) { + context.commit("updateLoadingAutocomplete", true) + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async getlevel(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var payload = { + token: one_token() + }; + + let response = await api.getlevel(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateLevelName", data.records[0].M_ApproveLevelName); + context.commit("updateApproveLevelID", data.records[0].M_ApproveLevelID); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + + async getDivisionUser(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var payload = { + token: one_token() + }; + + let response = await api.getDivisionUser(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + }; + + context.commit("updateApproveDivision", data.records[0].DivisionName); + context.commit("updateApproveDivisionUserID", data.records[0].M_UserDivisionDivisionID); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + + async approveRequest(context, payload) { + context.commit("updateLoadingSaveRequest", true); + try { + payload.token = one_token(); + let response = await api.approveRequest(payload); + if (response.status != "OK") { + context.commit("updateLoadingSaveRequest", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSaveRequest", false); + context.commit("update_dialogApprove", false); + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Request pengeluaran barang berhasil approved', + }); + context.dispatch("search"); + } + + } catch (e) { + context.commit("updateLoadingSaveRequest", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + + async rejectRequest(context, payload) { + context.commit("updateLoadingSaveRequest", true); + try { + payload.token = one_token(); + let response = await api.rejectRequest(payload); + if (response.status != "OK") { + context.commit("updateLoadingSaveRequest", false); + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateLoadingSaveRequest", false); + context.commit("update_dialogApprove", false); + context.commit("updateSnackbar", { + state: true, + type: 'success', + message: 'Request pengeluaran barang berhasil reject', + }); + context.dispatch("search"); + } + + } catch (e) { + context.commit("updateLoadingSaveRequest", false); + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + }, +}; \ No newline at end of file diff --git a/test/vuex/acc-one-request-item-out/store.js b/test/vuex/acc-one-request-item-out/store.js new file mode 100644 index 0000000..347b5f0 --- /dev/null +++ b/test/vuex/acc-one-request-item-out/store.js @@ -0,0 +1,11 @@ +import requester from "./modules/requester.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + requester: requester, + system: system, + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/acc-one-supplier-payment-approved-v4/api/api.js b/test/vuex/acc-one-supplier-payment-approved-v4/api/api.js new file mode 100644 index 0000000..8ac59e6 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-approved-v4/api/api.js @@ -0,0 +1,81 @@ +const URL = "/one-api/mockup/supplierpaymentapprovedv3/billv2/"; + +export async function search(params) { + try { + const response = await axios.post(URL + "search", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + const data = response.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function searchDetail(params) { + try { + const response = await axios.post(URL + "searchDetail", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + const data = response.data + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function getUserApproveLevel(params) { + try { + const response = await axios.post(URL + "getUserApproveLevel", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + const data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} + +export async function updateStatusPayment(params) { + try { + const response = await axios.post(URL + "updateStatusPayment", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + const data = response.data; + return data; + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-approved-v4/components/dialog-detail.vue b/test/vuex/acc-one-supplier-payment-approved-v4/components/dialog-detail.vue new file mode 100644 index 0000000..c31dc2a --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-approved-v4/components/dialog-detail.vue @@ -0,0 +1,282 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-approved-v4/components/one-main-content.vue b/test/vuex/acc-one-supplier-payment-approved-v4/components/one-main-content.vue new file mode 100644 index 0000000..d4ea23d --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-approved-v4/components/one-main-content.vue @@ -0,0 +1,264 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-approved-v4/index.php b/test/vuex/acc-one-supplier-payment-approved-v4/index.php new file mode 100644 index 0000000..8ea052b --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-approved-v4/index.php @@ -0,0 +1,60 @@ + + + + + + + + + + one + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-approved-v4/modules/suppayment.js b/test/vuex/acc-one-supplier-payment-approved-v4/modules/suppayment.js new file mode 100644 index 0000000..02b82b7 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-approved-v4/modules/suppayment.js @@ -0,0 +1,138 @@ +import * as api from '../api/api.js'; + +export default { + namespaced: true, + state: { + snackbar: { state: false, color: 'error', message: "" }, + userinfo: {}, + filterpay: { + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + status: "All", + search: "" + }, + list_status: ['All', 'Draft', 'Verified', 'Approved', 'Rejected', 'Completed'], + list_payment: { records: [], total: 1 }, + currentpage: 1, + + selected_payment: {}, + payment_items: {}, + dialog_detail: false, + operation_mode: 'view', + operation_loading: false + }, + mutations: { + update_userinfo(state, val) { + state.userinfo = val + }, + update_snackbar(state, val) { + state.snackbar = val + }, + update_filterpay(state, val) { + state.filterpay = val + }, + update_list_status(state, val) { + state.list_status = val + }, + update_list_payment(state, val) { + state.list_payment = val + }, + update_currentpage(state, val) { + state.currentpage = val + }, + update_selected_payment(state, val) { + state.selected_payment = val + }, + update_payment_items(state, val) { + state.payment_items = val + }, + update_dialog_detail(state, val) { + state.dialog_detail = val + }, + update_operation_mode(state, val) { + state.operation_mode = val + }, + update_operation_loading(state, val) { + state.operation_loading = val + } + }, + actions: { + async lookupUserApproveLevel(context) { + try { + const resp = await api.getUserApproveLevel({token: one_token()}); + if (resp.status != 'OK') { + throw new Error(resp.message); + } else { + context.commit('update_userinfo', resp.data); + } + } catch (error) { + const snack = { state: true, color: 'error', message: error.message } + context.commit("update_snackbar", snack) + } + }, + + async lookupPayment(context) { + try { + let param = { + ...context.state.filterpay, + currentpage: context.state.currentpage, + token: one_token() + } + const resp = await api.search(param) + if (resp.status != 'OK') { + throw new Error(resp.message); + } else { + context.commit("update_list_payment", resp.data) + } + } catch (error) { + const snack = { state: true, color: 'error', message: error.message } + context.commit("update_snackbar", snack) + } + }, + + async lookupPaymentItem(context) { + try { + let param = { + token: one_token(), + paymentID: context.state.selected_payment.SupplierPaymentID + }; + + const resp = await api.searchDetail(param); + if (resp.status != 'OK') { + throw new Error(resp.message); + } else { + context.commit("update_payment_items", resp.data); + } + } catch (error) { + const snack = { state: true, color: 'error', message: error.message } + context.commit("update_snackbar", snack) + } + }, + + async updateStatus(context) { + try { + context.state.operation_loading = true + let param = { + token: one_token(), + userlevel: context.state.userinfo.level ?? "0", + paymentID: context.state.selected_payment.SupplierPaymentID + } + + const resp = await api.updateStatusPayment(param) + if (resp.status != 'OK') { + throw new Error(resp.message); + } else { + const snack = { state: true, color: 'success', message: resp.data } + context.commit("update_snackbar", snack) + + context.dispatch("lookupPayment") + context.state.operation_loading = false + context.state.dialog_detail = false + } + } catch (error) { + const snack = { state: true, color: 'error', message: error.message } + context.commit("update_snackbar", snack) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-approved-v4/store.js b/test/vuex/acc-one-supplier-payment-approved-v4/store.js new file mode 100644 index 0000000..f5a4168 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-approved-v4/store.js @@ -0,0 +1,11 @@ +import system from '../../../apps/modules/system/system.js'; +import suppayment from './modules/suppayment.js'; +export const store = new Vuex.Store({ + modules: { + system: system, + suppayment: suppayment + }, + state: {}, + mutations: {}, + actions: {} +}) \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/api/bill.js b/test/vuex/acc-one-supplier-payment-failed/api/bill.js new file mode 100644 index 0000000..9d92761 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/api/bill.js @@ -0,0 +1,57 @@ +const URL = "/one-api/mockup/supplierpaymentfailed/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'bill/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchsupplier(prm) { + try { + var resp = await axios.post(URL + 'bill/searchsupplier', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchinvpayment(prm) { + try { + var resp = await axios.post(URL + 'bill/searchinvpayment', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/api/payment.js b/test/vuex/acc-one-supplier-payment-failed/api/payment.js new file mode 100644 index 0000000..238c9a6 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/api/payment.js @@ -0,0 +1,118 @@ +const URL = "/one-api/mockup/supplierpaymentfailed/"; + +export async function lookup_type(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_type',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function lookup_banks(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_banks',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function lookup_accounts(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_accounts',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function searchcard(token,prm) { + try { + var resp = await axios.post(URL + 'payment/searchcard',{token:token,search:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + +export async function pay(prm) { + try { + var resp = await axios.post(URL + 'payment/pay',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function delete_note(prm) { + try { + var resp = await axios.post(URL + 'payment/delete_note',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-supplier-payment-failed/api/paymentmanual.js b/test/vuex/acc-one-supplier-payment-failed/api/paymentmanual.js new file mode 100644 index 0000000..5af4e4d --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/api/paymentmanual.js @@ -0,0 +1,192 @@ +const URL = "/one-api/mockup/supplierpaymentfailed/"; + +export async function lookup_type(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_type',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function lookup_banks(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_banks',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function lookup_accounts(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_accounts',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function searchcard(token,prm) { + try { + var resp = await axios.post(URL + 'payment/searchcard',{token:token,search:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + +export async function pay(prm) { + try { + var resp = await axios.post(URL + 'payment/paymanual',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function delete_note(prm) { + try { + var resp = await axios.post(URL + 'payment/delete_note',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function confirm_note(prm) { + try { + var resp = await axios.post(URL + 'bill/confirm_note',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function selectpaymenttype(token) { + try { + var resp = await axios.post(URL + 'payment/selectpaymenttype',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function selectcard(token) { + try { + var resp = await axios.post(URL + 'payment/selectbank',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function selectedc(token) { + try { + var resp = await axios.post(URL + 'payment/selectaccount',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } diff --git a/test/vuex/acc-one-supplier-payment-failed/components/oneBillList.vue b/test/vuex/acc-one-supplier-payment-failed/components/oneBillList.vue new file mode 100644 index 0000000..204f3fd --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/components/oneBillList.vue @@ -0,0 +1,741 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentAuto.vue b/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentAuto.vue new file mode 100644 index 0000000..e327e13 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentAuto.vue @@ -0,0 +1,855 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentManual.vue b/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentManual.vue new file mode 100644 index 0000000..05516a8 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentManual.vue @@ -0,0 +1,1117 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentNew.vue b/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentNew.vue new file mode 100644 index 0000000..d959543 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/components/oneBillPaymentNew.vue @@ -0,0 +1,815 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/index.php b/test/vuex/acc-one-supplier-payment-failed/index.php new file mode 100644 index 0000000..71832b0 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/index.php @@ -0,0 +1,91 @@ + + + + + + + + One + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/acc-one-supplier-payment-failed/modules/bill.js b/test/vuex/acc-one-supplier-payment-failed/modules/bill.js new file mode 100644 index 0000000..852b7cc --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/modules/bill.js @@ -0,0 +1,210 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/bill.js" + +export default { + namespaced: true, + state: { + search_bill: 0, + search_error_message: '', + start_date: moment(new Date()).format('YYYY-MM-DD'), + end_date: moment(new Date()).format('YYYY-MM-DD'), + init_sdate: moment(new Date()).format('YYYY-MM-DD'), + init_edate: moment(new Date()).format('YYYY-MM-DD'), + search: '', + ssupplier: '', + isauto:'N', + bills: [], + total_bill: 0, + selected_bill: { + totalbill: 0, + mindp_percent: 0 + }, + save_error_message: '', + statuses: [{ + name: 'Belum Konfirmasi', + value: 'N' + }, { + name: 'Konfirmasi', + value: 'Y' + }], + selected_status: { + name: 'Belum Konfirmasi', + value: 'N' + }, + open_alert_no_pay: false, + msg_alert_no_pay: "Loh ... Gak jadi bayar dong ?", + current_page: 1, + total_page: 0, + pay_disabled: 'Y', + get_data_status: 0, + get_data_error_message: '', + dialog_form_order: false, + suppliers: [], + supplier: {}, + invpayments: [], + invpayment: {}, + errors: [], + act_comp: 'new', + in_saving: false + }, + mutations: { + update_in_saving(state, val) { + state.in_saving = val + }, + update_act_comp(state, val) { + state.act_comp = val + }, + update_errors(state, val) { + state.errors = val + }, + update_suppliers(state, val) { + state.suppliers = val + }, + update_supplier(state, val) { + state.supplier = val + }, + update_invpayments(state, val) { + state.invpayments = val + }, + update_invpayment(state, val) { + state.invpayment = val + }, + update_dialog_form_order(state, val) { + state.dialog_form_order = val + }, + update_init_sdate(state, val) { + state.init_sdate = val + }, + update_init_edate(state, val) { + state.init_edate = val + }, + update_pay_disabled(state, val) { + state.pay_disabled = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_search_error_message(state, bill) { + state.search_error_message = bill + }, + update_search_bill(state, bill) { + state.search_bill = bill + }, + update_bills(state, data) { + state.bills = data.records + state.total_bill = data.total + state.total_page = data.total + }, + update_selected_bill(state, val) { + state.selected_bill = val + }, + update_start_date(state, val) { + state.start_date = val + }, + update_end_date(state, val) { + state.end_date = val + }, + update_search(state, val) { + state.search = val + }, + update_ssupplier(state, val) { + state.ssupplier = val + }, + update_selected_status(state, val) { + state.selected_status = val + }, + update_open_alert_no_pay(state, val) { + state.open_alert_no_pay = val + }, + update_msg_alert_no_pay(state, val) { + state.msg_alert_no_pay = val + }, + update_isauto(state, val) { + state.isauto = val + }, + update_get_data_status(state, val) { + state.get_data_status = val + }, + update_get_data_error_message(state, val) { + state.get_data_error_message = val + } + }, + actions: { + async search(context, prm) { + context.commit("update_search_bill", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_bill", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_bill", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_bills", data) + context.commit("update_total_page", data.total) + if (prm.lastidx === 0 && data.total > 0) { + context.commit("update_selected_bill", data.records[0]) + + } else if (prm.lastidx > 0 && data.total > 0) { + context.commit("update_selected_bill", data.records[prm.lastidx]) + } else { + context.commit("update_selected_bill", '') + } + + } + } catch (e) { + context.commit("update_search_bill", 3) + context.commit("update_search_error_message", e.message) + console.log(e) + } + }, + async searchsupplier(context, prm) { + context.commit("update_search_bill", 1) + try { + prm.token = one_token() + let resp = await api.searchsupplier(prm) + if (resp.status != "OK") { + context.commit("update_search_bill", 3) + } else { + context.commit("update_search_bill", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_suppliers", resp.data.records) + } + } catch (e) { + context.commit("update_search_bill", 3) + } + }, + async searchinvpayment(context, prm) { + context.commit("update_search_bill", 1) + try { + prm.token = one_token() + let resp = await api.searchinvpayment(prm) + if (resp.status != "OK") { + context.commit("update_search_bill", 3) + } else { + context.commit("update_search_bill", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_invpayments", resp.data.records) + } + } catch (e) { + context.commit("update_search_bill", 3) + } + }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/modules/paymentmanual.js b/test/vuex/acc-one-supplier-payment-failed/modules/paymentmanual.js new file mode 100644 index 0000000..06b57a4 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/modules/paymentmanual.js @@ -0,0 +1,440 @@ +import * as api from "../api/paymentmanual.js" + +export default { + namespaced: true, + state: { + lookup_status: 0, + lookup_error_message: '', + types: [], + total_payment: 0, + reload_after_save: false, + dialog_pay_success: false, + paynumber: '', + notes: [], + tagihans: [], + dialog_delete: false, + msg_delete: '', + note_delete: '', + nota_delete: {}, + dialog_confirm: false, + msg_confirm: '', + note_confirm: '', + nota_confirm: {}, + nota_form: {}, + open_print_note: false, + idx: 0, + last_payments: {}, + payment_total: 0, + banks: [], + disable_btn_pay: 'Y', + ordertests: [], + isauto: 'N', + paymenttypes: [], + paymenttype: { + M_PaymentTypeID: '1', + M_PaymentTypeName: 'Cash' + }, + cards: [], + card: {}, + edcs: [], + edc: {}, + accounts: [], + account: {}, + bar_chx_all: false, + selected_tagihan: {}, + indeterminatex: false, + in_saving: false, + xbayar: 0, + open_dialog_info:false, + msg_info:'' + }, + mutations: { + update_open_dialog_info(state,val){ + state.open_dialog_info = val + }, + update_msg_info(state,val){ + state.msg_info = val + }, + update_xbayar(state, val) { + state.xbayar = val + }, + update_in_saving(state, val) { + state.in_saving = val + }, + update_disable_btn_pay(state, val) { + state.disable_btn_pay = val + }, + update_banks(state, val) { + state.banks = val + }, + update_lookup_error_message(state, val) { + state.lookup_error_message = val + }, + update_lookup_status(state, status) { + state.lookup_status = status + }, + update_types(state, data) { + state.types = data.records + state.total_type = data.total + }, + update_selected_status(state, val) { + state.selected_status = val + }, + update_total_payment(state, val) { + state.total_payment = val + }, + update_reload_after_save(state, val) { + state.reload_after_save = val + }, + update_dialog_pay_success(state, val) { + state.dialog_pay_success = val + }, + update_paynumber(state, val) { + state.paynumber = val + }, + update_notes(state, val) { + state.notes = val + }, + update_tagihans(state, val) { + state.tagihans = val + }, + update_dialog_delete(state, val) { + state.dialog_delete = val + }, + update_note_delete(state, val) { + state.note_delete = val + }, + update_msg_delete(state, val) { + state.msg_delete = val + }, + update_nota_delete(state, val) { + state.nota_delete = val + }, + update_dialog_confirm(state, val) { + state.dialog_confirm = val + }, + update_note_confirm(state, val) { + state.note_confirm = val + }, + update_msg_confirm(state, val) { + state.msg_confirm = val + }, + update_nota_confirm(state, val) { + state.nota_confirm = val + }, + update_nota_form(state, val) { + state.nota_form = val + }, + update_open_print_note(state, val) { + state.open_print_note = val + }, + update_idx(state, val) { + state.idx = val + }, + update_last_payments(state, val) { + state.last_payments = val + }, + update_ordertests(state, data) { + state.ordertests = data + }, + update_isauto(state, val) { + state.isauto = val + }, + update_paymenttypes(state, data) { + state.paymenttypes = data + }, + update_paymenttype(state, val) { + state.paymenttype = val + }, + update_cards(state, data) { + state.cards = data + }, + update_card(state, val) { + state.card = val + }, + update_edcs(state, data) { + state.edcs = data + }, + update_edc(state, val) { + state.edc = val + }, + update_accounts(state, data) { + state.accounts = data + }, + update_account(state, val) { + state.account = val + }, + update_bar_chx_all(state, val) { + state.bar_chx_all = val + }, + update_indeterminatex(state, val) { + state.indeterminatex = val + }, + update_selected_tagihan(state, val) { + state.selected_tagihan = val + } + }, + actions: { + async lookup_type(context, prm) { + context.commit("update_lookup_status", 1) + try { + let resp = await api.lookup_type(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_types", data) + + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async lookup_banks(context) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let resp = await api.lookup_banks(one_token()) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_paymenttypes", resp.data.records.paymenttypes) + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + }, + async lookup_accounts(context) { + context.commit("update_lookup_status", 1) + try { + let resp = await api.lookup_accounts(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_accounts", data.records) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async searchcard(context, prm) { + context.commit("update_lookup_status", 1) + try { + let resp = await api.searchcard(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + } else { + context.commit("update_lookup_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_cards", resp.data.records) + } + } catch (e) { + context.commit("update_lookup_status", 3) + } + }, + async pay(context, prm) { + context.commit("update_lookup_status", 1) + try { + prm.token = one_token() + let resp = await api.pay(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records.types, + total: resp.data.total + } + let xnumber = resp.data.records.data.numberx + let id = resp.data.records.data.idx + context.commit("update_disable_btn_pay", 'Y') + context.commit("update_idx", id) + context.commit("update_total_payment", 0) + context.commit("update_paynumber", "Pembayaran nomor " + xnumber + " telah berhasil") + context.commit("update_dialog_pay_success", true) + context.commit("update_in_saving", false) + context.commit("update_xbayar", 0) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async delete_note(context, prm) { + context.commit("update_lookup_status", 1) + try { + prm.token = one_token() + let resp = await api.delete_note(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let xmsg = "Nota nomor " + prm.nota.note_number + " telah dihapus" + context.commit("update_msg_delete", xmsg) + context.commit("update_note_delete", '') + context.commit("update_nota_delete", {}) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async confirm_note(context, prm) { + context.commit("update_lookup_status", 1) + try { + prm.token = one_token() + let resp = await api.confirm_note(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let xmsg = "Nota nomor " + prm.nota.note_number + " telah dibatalkan" + context.commit("update_msg_confirm", xmsg) + context.commit("update_nota_confirm", {}) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async selectpaymenttype(context) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let resp = await api.selectpaymenttype(one_token()) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_paymenttypes", resp.data.records.paymenttypes) + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + }, + async selectcard(context) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let resp = await api.selectcard(one_token()) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_cards", resp.data.records.banks) + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + }, + async selectedc(context) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let resp = await api.selectedc(one_token()) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_edcs", resp.data.records.accounts) + context.commit("update_accounts", resp.data.records.accounts) + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/modules/paymentnew.js b/test/vuex/acc-one-supplier-payment-failed/modules/paymentnew.js new file mode 100644 index 0000000..983631b --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/modules/paymentnew.js @@ -0,0 +1,255 @@ +import * as api from "../api/payment.js" + +export default { + namespaced: true, + state: { + lookup_status:0, + lookup_error_message:'', + types: [], + total_payment:0, + reload_after_save: false, + dialog_pay_success:false, + paynumber :'', + notes :[], + dialog_delete:false, + msg_delete:'', + note_delete:'', + nota_delete:{}, + open_print_note:false, + idx:0, + last_payments:{}, + payment_total: 0, + banks:[], + disable_btn_pay:'Y', + accounts:[], + ordertests:[], + isauto: 'N', + in_saving: false, + open_dialog_info:false, + msg_info:'' + }, + mutations: { + update_open_dialog_info(state,val){ + state.open_dialog_info = val + }, + update_msg_info(state,val){ + state.msg_info = val + }, + update_in_saving(state, val) { + state.in_saving = val + }, + update_accounts(state,val) { + state.accounts = val + }, + update_disable_btn_pay(state,val) { + state.disable_btn_pay = val + }, + update_banks(state,val) { + state.banks = val + }, + update_lookup_error_message(state,val) { + state.lookup_error_message = val + }, + update_lookup_status(state,status) { + state.lookup_status = status + }, + update_types(state,data) { + state.types = data.records + state.total_type = data.total + }, + update_selected_status(state,val) { + state.selected_status=val + }, + update_total_payment(state,val) { + state.total_payment=val + }, + update_reload_after_save(state,val) { + state.reload_after_save=val + }, + update_dialog_pay_success(state,val) { + state.dialog_pay_success=val + }, + update_paynumber(state,val) { + state.paynumber=val + }, + update_notes(state,val) { + state.notes=val + }, + update_dialog_delete(state,val) { + state.dialog_delete=val + }, + update_note_delete(state,val) { + state.note_delete=val + }, + update_msg_delete(state,val) { + state.msg_delete=val + }, + update_nota_delete(state,val) { + state.nota_delete=val + }, + update_open_print_note(state,val) { + state.open_print_note=val + }, + update_idx(state,val) { + state.idx=val + }, + update_last_payments(state,val) { + state.last_payments=val + }, + update_ordertests(state,data){ + state.ordertests = data + }, + update_isauto(state, val) { + state.isauto = val + } + }, + actions: { + async lookup_type(context,prm) { + context.commit("update_lookup_status",1) + try { + let resp= await api.lookup_type(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_types",data) + + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + }, + async lookup_banks(context) { + context.commit("update_lookup_status",1) + try { + let resp= await api.lookup_banks(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_banks",data.records) + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + }, + async lookup_accounts(context) { + context.commit("update_lookup_status",1) + try { + let resp= await api.lookup_accounts(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_accounts",data.records) + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + }, + async searchcard(context,prm) { + context.commit("update_lookup_status",1) + try { + let resp= await api.searchcard(one_token(),prm) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + } else { + context.commit("update_lookup_status",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_cards",resp.data.records) + } + } catch(e) { + context.commit("update_lookup_status",3) + } + }, + async pay(context,prm) { + context.commit("update_lookup_status",1) + try { + prm.token = one_token() + let resp= await api.pay(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let data = { + records : resp.data.records.types, + total: resp.data.total + } + let xnumber = resp.data.records.data.numberx + let id = resp.data.records.data.idx + var xobj = context.state.types + //console.log(xobj) + xobj.forEach(function(obj){ + obj.chex = false + obj.leftvalue = 0 + obj.rightvalue = 0 + obj.selected_card = {id:0,name:''} + obj.selected_edc = {id:0,name:''} + obj.selected_account = {id:0,name:''} + }) + var xray = {records:xobj,total:xobj.length} + context.commit("update_types",xray) + context.commit("update_disable_btn_pay",'Y') + console.log(context.state.types) + context.commit("update_last_payments",prm.payments) + context.commit("update_idx",id) + context.commit("update_total_payment",0) + context.commit("update_paynumber","Pembayaran nomor "+xnumber+" telah berhasil") + context.commit("update_dialog_pay_success",true) + context.commit("update_in_saving", false) + + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + }, + async delete_note(context,prm) { + context.commit("update_lookup_status",1) + try { + prm.token = one_token() + let resp= await api.delete_note(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let xmsg = "Nota nomor "+prm.nota.note_number+" telah dihapus" + context.commit("update_msg_delete",xmsg) + context.commit("update_note_delete",'') + context.commit("update_nota_delete",{}) + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-failed/store.js b/test/vuex/acc-one-supplier-payment-failed/store.js new file mode 100644 index 0000000..b24b8ff --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-failed/store.js @@ -0,0 +1,31 @@ +// State +// data ... +// Mutations +// +// +// Actions +import bill from "./modules/bill.js"; +import paymentnew from "./modules/paymentnew.js"; +import paymentmanual from "./modules/paymentmanual.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + bill: bill, + paymentnew:paymentnew, + paymentmanual: paymentmanual, + system:system + }, + state: { + tab_selected: 'pasien-dokter' + }, + mutations: { + change_tab(state, ntab) { + state.tab_selected = ntab + } + }, + actions: { + change_tab(context, ntab) { + context.commit('change_tab', ntab) + } + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-v4/api/bill.js b/test/vuex/acc-one-supplier-payment-v4/api/bill.js new file mode 100644 index 0000000..7c06252 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/api/bill.js @@ -0,0 +1,20 @@ +const URL = "/one-api/mockup/supplierpaymentv4/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'bill/search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-supplier-payment-v4/api/payment.js b/test/vuex/acc-one-supplier-payment-v4/api/payment.js new file mode 100644 index 0000000..27abbf4 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/api/payment.js @@ -0,0 +1,118 @@ +const URL = "/one-api/mockup/supplierpaymentv4/"; + +export async function lookup_type(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_type',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function lookup_banks(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_banks',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function lookup_accounts(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_accounts',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function searchcard(token,prm) { + try { + var resp = await axios.post(URL + 'payment/searchcard',{token:token,search:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + +export async function pay(prm) { + try { + var resp = await axios.post(URL + 'payment/pay',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function delete_note(prm) { + try { + var resp = await axios.post(URL + 'payment/delete_note',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/acc-one-supplier-payment-v4/api/paymentmanual.js b/test/vuex/acc-one-supplier-payment-v4/api/paymentmanual.js new file mode 100644 index 0000000..63942e5 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/api/paymentmanual.js @@ -0,0 +1,213 @@ +const URL = "/one-api/mockup/supplierpaymentv4/"; + +export async function lookup_type(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_type',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function lookup_banks(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_banks',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function lookup_accounts(token) { + try { + var resp = await axios.post(URL + 'payment/lookup_accounts',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function searchcard(token,prm) { + try { + var resp = await axios.post(URL + 'payment/searchcard',{token:token,search:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + +export async function pay(prm) { + try { + var resp = await axios.post(URL + 'payment/paymanual',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function editpay(prm) { + try { + var resp = await axios.post(URL + 'payment/editpaymanual',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function delete_note(prm) { + try { + var resp = await axios.post(URL + 'payment/delete_note',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function edit_note(prm) { + try { + var resp = await axios.post(URL + 'payment/edit_note',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function selectpaymenttype(prm) { + try { + var resp = await axios.post(URL + 'payment/selectpaymenttype',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function selectcard(token) { + try { + var resp = await axios.post(URL + 'payment/selectbank',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function selectedc(token) { + try { + var resp = await axios.post(URL + 'payment/selectaccount',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } diff --git a/test/vuex/acc-one-supplier-payment-v4/components/oneBillList.vue b/test/vuex/acc-one-supplier-payment-v4/components/oneBillList.vue new file mode 100644 index 0000000..c876375 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/components/oneBillList.vue @@ -0,0 +1,445 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentAuto.vue b/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentAuto.vue new file mode 100644 index 0000000..e327e13 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentAuto.vue @@ -0,0 +1,855 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentManual.vue b/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentManual.vue new file mode 100644 index 0000000..ea57a9d --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentManual.vue @@ -0,0 +1,1372 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentNew.vue b/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentNew.vue new file mode 100644 index 0000000..d959543 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/components/oneBillPaymentNew.vue @@ -0,0 +1,815 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-v4/index.php b/test/vuex/acc-one-supplier-payment-v4/index.php new file mode 100644 index 0000000..9ae3d25 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/index.php @@ -0,0 +1,96 @@ + + + + + + + + One + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/acc-one-supplier-payment-v4/modules/bill.js b/test/vuex/acc-one-supplier-payment-v4/modules/bill.js new file mode 100644 index 0000000..a3e2c72 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/modules/bill.js @@ -0,0 +1,265 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/bill.js" + +export default { + namespaced: true, + state: { + search_bill: 0, + search_error_message: '', + start_date: moment(new Date()).format('YYYY-MM-DD'), + end_date: moment(new Date()).format('YYYY-MM-DD'), + init_sdate: moment(new Date()).format('YYYY-MM-DD'), + init_edate: moment(new Date()).format('YYYY-MM-DD'), + search: '', + ssupplier: '', + isauto:'N', + bills: [], + total_bill: 0, + selected_bill: { + totalbill: 0, + mindp_percent: 0 + }, + save_error_message: '', + statuses: [{ + name: 'Belum Pembayaran', + value: 'N' + }, { + name: 'Sudah Pembayaran', + value: 'Y' + }], + selected_status: { + name: 'Belum Pembayaran', + value: 'N' + }, + open_alert_no_pay: false, + msg_alert_no_pay: "Loh ... Gak jadi bayar dong ?", + current_page: 1, + total_page: 0, + pay_disabled: 'Y', + get_data_status: 0, + get_data_error_message: '' + }, + mutations: { + update_init_sdate(state, val) { + state.init_sdate = val + }, + update_init_edate(state, val) { + state.init_edate = val + }, + update_pay_disabled(state, val) { + state.pay_disabled = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_search_error_message(state, bill) { + state.search_error_message = bill + }, + update_search_bill(state, bill) { + state.search_bill = bill + }, + update_bills(state, data) { + state.bills = data.records + state.total_bill = data.total + state.total_page = data.total + }, + update_selected_bill(state, val) { + state.selected_bill = val + }, + update_start_date(state, val) { + state.start_date = val + }, + update_end_date(state, val) { + state.end_date = val + }, + update_search(state, val) { + state.search = val + }, + update_ssupplier(state, val) { + state.ssupplier = val + }, + update_selected_status(state, val) { + state.selected_status = val + }, + update_open_alert_no_pay(state, val) { + state.open_alert_no_pay = val + }, + update_msg_alert_no_pay(state, val) { + state.msg_alert_no_pay = val + }, + update_isauto(state, val) { + state.isauto = val + }, + update_get_data_status(state, val) { + state.get_data_status = val + }, + update_get_data_error_message(state, val) { + state.get_data_error_message = val + } + }, + actions: { + async search(context, prm) { + context.commit("update_search_bill", 1) + try { + prm.token = one_token() + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_search_bill", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_bill", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_bills", data) + context.commit("update_total_page", data.total) + if (prm.lastidx === 0 && data.total > 0) { + context.commit("update_selected_bill", data.records[0]) + if (!_.isEmpty(data.records[0])) { + context.commit("paymentmanual/update_xbayar", data.records[0].totalbill, { + root: true + }) + context.commit("paymentmanual/update_xtanggalbayar", data.records[0].SupplierInvoiceDraftPaymentDate, { + root: true + }) + context.commit("paymentnew/update_notes", data.records[0].notes, { + root: true + }) + context.commit("paymentmanual/update_notes", data.records[0].notes, { + root: true + }) + + + + + if (data.records[0].flaglunas === 'N') { + context.commit("paymentmanual/update_tagihans", data.records[0].tagihans, { + root: true + }) + } else { + context.commit("paymentmanual/update_tagihans", [], { + root: true + }) + } + + var arr = context.rootState.paymentmanual.tagihans + var value = true + context.commit("paymentmanual/update_indeterminatex", false, {root: true}) + context.commit("paymentmanual/update_bar_chx_all", value, {root: true}) + + arr.forEach((el) => { + el.chex = value + el.tagihan_bayar = value == true ? el.tagihan_tagihan : 0 + }) + + var selected = _.filter(arr, function (o) { + return o.chex; + }) + context.commit("paymentmanual/update_selected_tagihan", selected, { + root: true + }) + + var xval = context.rootState.paymentmanual.selected_tagihan + var valx = 0 + xval.forEach(function (obj) { + valx += parseInt(obj.tagihan_bayar) + }) + let totpaid = valx + context.commit("paymentmanual/update_total_payment", totpaid, {root: true}) + } else { + context.commit("paymentnew/update_notes", [], { + root: true + }) + context.commit("paymentmanual/update_notes", [], { + root: true + }) + context.commit("paymentmanual/update_tagihans", [], { + root: true + }) + + } + } else if (prm.lastidx > 0 && data.total > 0) { + context.commit("update_selected_bill", data.records[0]) + context.commit("paymentmanual/update_xbayar", data.records[0].totalbill, { + root: true + }) + context.commit("paymentnew/update_notes", data.records[prm.lastidx].notes, { + root: true + }) + context.commit("paymentmanual/update_notes", data.records[prm.lastidx].notes, { + root: true + }) + context.commit("paymentmanual/update_xtanggalbayar", data.records[prm.lastidx].SupplierInvoiceDraftPaymentDate, { + root: true + }) + if (data.records[prm.lastidx].flaglunas === 'N') { + context.commit("paymentmanual/update_tagihans", data.records[prm.lastidx].tagihans, { + root: true + }) + } else { + context.commit("paymentmanual/update_tagihans", [], { + root: true + }) + } + var arr = context.rootState.paymentmanual.tagihans + var value = true + context.commit("paymentmanual/update_indeterminatex", false, {root: true}) + context.commit("paymentmanual/update_bar_chx_all", value, {root: true}) + + arr.forEach((el) => { + el.chex = value + el.tagihan_bayar = value == true ? el.tagihan_tagihan : 0 + }) + + var selected = _.filter(arr, function (o) { + return o.chex; + }) + context.commit("paymentmanual/update_selected_tagihan", selected, { + root: true + }) + + var xval = context.rootState.paymentmanual.selected_tagihan + var valx = 0 + xval.forEach(function (obj) { + valx += parseInt(obj.tagihan_bayar) + }) + let totpaid = valx + context.commit("paymentmanual/update_total_payment", totpaid, {root: true}) + + } else { + context.commit("update_selected_bill", '') + context.commit("paymentnew/update_notes", [], { + root: true + }) + context.commit("paymentmanual/update_notes", [], { + root: true + }) + context.commit("paymentmanual/update_tagihans", [], { + root: true + }) + context.commit("paymentmanual/update_xtanggalbayar", '', { + root: true + }) + context.commit("paymentmanual/update_xbayar", 0, { + root: true + }) + context.commit("paymentmanual/update_total_payment", 0, {root: true}) + context.commit("paymentmanual/update_bar_chx_all", false, {root: true}) + } + + } + } catch (e) { + context.commit("update_search_bill", 3) + context.commit("update_search_error_message", e.message) + console.log(e) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-v4/modules/paymentmanual.js b/test/vuex/acc-one-supplier-payment-v4/modules/paymentmanual.js new file mode 100644 index 0000000..add03a5 --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/modules/paymentmanual.js @@ -0,0 +1,525 @@ +import * as api from "../api/paymentmanual.js" + +export default { + namespaced: true, + state: { + lookup_status: 0, + lookup_error_message: '', + types: [], + total_payment: 0, + reload_after_save: false, + dialog_pay_success: false, + paynumber: '', + notes: [], + tagihans: [], + dialog_delete: false, + msg_delete: '', + note_delete: '', + nota_delete: {}, + dialog_edit: false, + msg_edit: '', + note_edit: '', + nota_edit: {}, + open_print_note: false, + idx: 0, + last_payments: {}, + payment_total: 0, + banks: [], + disable_btn_pay: 'Y', + ordertests: [], + isauto: 'N', + paymenttypes: [], + paymenttype: {}, + paymenttypes_edit: [], + paymenttype_edit: {}, + cards: [], + card: {}, + edcs: [], + edc: {}, + accounts: [], + account: {}, + bar_chx_all: false, + selected_tagihan: {}, + indeterminatex: false, + in_saving: false, + xbayar: 0, + open_dialog_info:false, + msg_info:'', + a_coa_search: '', + a_loading_coa: false, + xtanggalbayar: '' + }, + mutations: { + update_xtanggalbayar(state, val) { + state.xtanggalbayar = val + }, + update_a_coa_search(state, val) { + state.a_coa_search = val + }, + update_a_loading_coa(state, val) { + state.a_loading_coa = val + }, + update_open_dialog_info(state,val){ + state.open_dialog_info = val + }, + update_msg_info(state,val){ + state.msg_info = val + }, + update_xbayar(state, val) { + state.xbayar = val + }, + update_in_saving(state, val) { + state.in_saving = val + }, + update_disable_btn_pay(state, val) { + state.disable_btn_pay = val + }, + update_banks(state, val) { + state.banks = val + }, + update_lookup_error_message(state, val) { + state.lookup_error_message = val + }, + update_lookup_status(state, status) { + state.lookup_status = status + }, + update_types(state, data) { + state.types = data.records + state.total_type = data.total + }, + update_selected_status(state, val) { + state.selected_status = val + }, + update_total_payment(state, val) { + state.total_payment = val + }, + update_reload_after_save(state, val) { + state.reload_after_save = val + }, + update_dialog_pay_success(state, val) { + state.dialog_pay_success = val + }, + update_paynumber(state, val) { + state.paynumber = val + }, + update_notes(state, val) { + state.notes = val + }, + update_tagihans(state, val) { + state.tagihans = val + }, + update_dialog_delete(state, val) { + state.dialog_delete = val + }, + update_note_delete(state, val) { + state.note_delete = val + }, + update_msg_delete(state, val) { + state.msg_delete = val + }, + update_nota_delete(state, val) { + state.nota_delete = val + }, + update_dialog_edit(state, val) { + state.dialog_edit = val + }, + update_note_edit(state, val) { + state.note_edit = val + }, + update_msg_edit(state, val) { + state.msg_edit = val + }, + update_nota_edit(state, val) { + state.nota_edit = val + }, + update_open_print_note(state, val) { + state.open_print_note = val + }, + update_idx(state, val) { + state.idx = val + }, + update_last_payments(state, val) { + state.last_payments = val + }, + update_ordertests(state, data) { + state.ordertests = data + }, + update_isauto(state, val) { + state.isauto = val + }, + update_paymenttypes(state, data) { + state.paymenttypes = data + }, + update_paymenttype(state, val) { + state.paymenttype = val + }, + update_paymenttypes_edit(state, data) { + state.paymenttypes_edit = data + }, + update_paymenttype_edit(state, val) { + state.paymenttype_edit = val + }, + update_cards(state, data) { + state.cards = data + }, + update_card(state, val) { + state.card = val + }, + update_edcs(state, data) { + state.edcs = data + }, + update_edc(state, val) { + state.edc = val + }, + update_accounts(state, data) { + state.accounts = data + }, + update_account(state, val) { + state.account = val + }, + update_bar_chx_all(state, val) { + state.bar_chx_all = val + }, + update_indeterminatex(state, val) { + state.indeterminatex = val + }, + update_selected_tagihan(state, val) { + state.selected_tagihan = val + } + }, + actions: { + async lookup_type(context, prm) { + context.commit("update_lookup_status", 1) + try { + let resp = await api.lookup_type(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_types", data) + + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async lookup_banks(context) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let resp = await api.lookup_banks(one_token()) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_paymenttypes", resp.data.records.paymenttypes) + context.commit("update_paymenttypes_edit", resp.data.records.paymenttypes_edit) + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + }, + async lookup_accounts(context) { + context.commit("update_lookup_status", 1) + try { + let resp = await api.lookup_accounts(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_accounts", data.records) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async searchcard(context, prm) { + context.commit("update_lookup_status", 1) + try { + let resp = await api.searchcard(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + } else { + context.commit("update_lookup_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_cards", resp.data.records) + } + } catch (e) { + context.commit("update_lookup_status", 3) + } + }, + async pay(context, prm) { + context.commit("update_lookup_status", 1) + try { + prm.token = one_token() + let resp = await api.pay(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records.types, + total: resp.data.total + } + let xnumber = resp.data.records.data.numberx + let id = resp.data.records.data.idx + context.commit("update_disable_btn_pay", 'Y') + context.commit("update_idx", id) + context.commit("update_total_payment", 0) + context.commit("update_paynumber", "Payment Instruction nomor " + xnumber + " telah berhasil") + context.commit("update_dialog_pay_success", true) + context.commit("update_in_saving", false) + context.commit("update_xbayar", 0) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async editpay(context, prm) { + context.commit("update_lookup_status", 1) + try { + prm.token = one_token() + let resp = await api.editpay(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records.types, + total: resp.data.total + } + let xnumber = prm.xnumber + let id = prm.orderid + context.commit("update_disable_btn_pay", 'Y') + context.commit("update_idx", id) + context.commit("update_total_payment", 0) + context.commit("update_paynumber", "Payment Instruction nomor " + xnumber + " telah berhasil di ubah") + context.commit("update_dialog_pay_success", true) + context.commit("update_in_saving", false) + context.commit("update_xbayar", 0) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async edit_note(context, prm) { + context.commit("update_lookup_status", 1) + try { + prm.token = one_token() + let resp = await api.edit_note(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let xmsg = "Nota nomor " + prm.note_number + " telah diubah" + context.commit("update_msg_edit", xmsg) + //context.commit("update_dialog_edit", false) + context.commit("update_nota_edit", {}) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async delete_note(context, prm) { + context.commit("update_lookup_status", 1) + try { + prm.token = one_token() + let resp = await api.delete_note(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_status", 2) + context.commit("update_lookup_error_message", "") + let xmsg = "Nota nomor " + prm.nota.note_number + " telah dihapus" + context.commit("update_msg_delete", xmsg) + context.commit("update_note_delete", '') + context.commit("update_nota_delete", {}) + } + } catch (e) { + context.commit("update_lookup_status", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async selectpaymenttype(context,payload) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let prm = {}; + prm.token = one_token() + prm.search = payload.search + let resp = await api.selectpaymenttype(prm) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_paymenttypes", resp.data.records.paymenttypes) + context.commit("update_paymenttypes_edit", resp.data.records.paymenttypes) + + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + }, + async selectpaymenttypeold(context) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let resp = await api.selectpaymenttype(one_token()) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_paymenttypes", resp.data.records.paymenttypes) + context.commit("update_paymenttypes_edit", resp.data.records.paymenttypes) + + context.commit("update_paymenttype", resp.data.records.paymenttypes[0]) + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + }, + async selectcard(context) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let resp = await api.selectcard(one_token()) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_cards", resp.data.records.banks) + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + }, + async selectedc(context) { + context.commit("bill/update_get_data_status", 1, { + root: true + }) + try { + let resp = await api.selectedc(one_token()) + if (resp.status != "OK") { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", resp.message, { + root: true + }) + } else { + context.commit("bill/update_get_data_status", 2, { + root: true + }) + context.commit("bill/update_get_data_error_message", "", { + root: true + }) + context.commit("update_edcs", resp.data.records.accounts) + context.commit("update_accounts", resp.data.records.accounts) + } + } catch (e) { + context.commit("bill/update_get_data_status", 3, { + root: true + }) + context.commit("bill/update_get_data_error_message", e.message, { + root: true + }) + console.log(e) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-v4/modules/paymentnew.js b/test/vuex/acc-one-supplier-payment-v4/modules/paymentnew.js new file mode 100644 index 0000000..983631b --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/modules/paymentnew.js @@ -0,0 +1,255 @@ +import * as api from "../api/payment.js" + +export default { + namespaced: true, + state: { + lookup_status:0, + lookup_error_message:'', + types: [], + total_payment:0, + reload_after_save: false, + dialog_pay_success:false, + paynumber :'', + notes :[], + dialog_delete:false, + msg_delete:'', + note_delete:'', + nota_delete:{}, + open_print_note:false, + idx:0, + last_payments:{}, + payment_total: 0, + banks:[], + disable_btn_pay:'Y', + accounts:[], + ordertests:[], + isauto: 'N', + in_saving: false, + open_dialog_info:false, + msg_info:'' + }, + mutations: { + update_open_dialog_info(state,val){ + state.open_dialog_info = val + }, + update_msg_info(state,val){ + state.msg_info = val + }, + update_in_saving(state, val) { + state.in_saving = val + }, + update_accounts(state,val) { + state.accounts = val + }, + update_disable_btn_pay(state,val) { + state.disable_btn_pay = val + }, + update_banks(state,val) { + state.banks = val + }, + update_lookup_error_message(state,val) { + state.lookup_error_message = val + }, + update_lookup_status(state,status) { + state.lookup_status = status + }, + update_types(state,data) { + state.types = data.records + state.total_type = data.total + }, + update_selected_status(state,val) { + state.selected_status=val + }, + update_total_payment(state,val) { + state.total_payment=val + }, + update_reload_after_save(state,val) { + state.reload_after_save=val + }, + update_dialog_pay_success(state,val) { + state.dialog_pay_success=val + }, + update_paynumber(state,val) { + state.paynumber=val + }, + update_notes(state,val) { + state.notes=val + }, + update_dialog_delete(state,val) { + state.dialog_delete=val + }, + update_note_delete(state,val) { + state.note_delete=val + }, + update_msg_delete(state,val) { + state.msg_delete=val + }, + update_nota_delete(state,val) { + state.nota_delete=val + }, + update_open_print_note(state,val) { + state.open_print_note=val + }, + update_idx(state,val) { + state.idx=val + }, + update_last_payments(state,val) { + state.last_payments=val + }, + update_ordertests(state,data){ + state.ordertests = data + }, + update_isauto(state, val) { + state.isauto = val + } + }, + actions: { + async lookup_type(context,prm) { + context.commit("update_lookup_status",1) + try { + let resp= await api.lookup_type(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_types",data) + + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + }, + async lookup_banks(context) { + context.commit("update_lookup_status",1) + try { + let resp= await api.lookup_banks(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_banks",data.records) + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + }, + async lookup_accounts(context) { + context.commit("update_lookup_status",1) + try { + let resp= await api.lookup_accounts(one_token()) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_accounts",data.records) + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + }, + async searchcard(context,prm) { + context.commit("update_lookup_status",1) + try { + let resp= await api.searchcard(one_token(),prm) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + } else { + context.commit("update_lookup_status",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_cards",resp.data.records) + } + } catch(e) { + context.commit("update_lookup_status",3) + } + }, + async pay(context,prm) { + context.commit("update_lookup_status",1) + try { + prm.token = one_token() + let resp= await api.pay(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let data = { + records : resp.data.records.types, + total: resp.data.total + } + let xnumber = resp.data.records.data.numberx + let id = resp.data.records.data.idx + var xobj = context.state.types + //console.log(xobj) + xobj.forEach(function(obj){ + obj.chex = false + obj.leftvalue = 0 + obj.rightvalue = 0 + obj.selected_card = {id:0,name:''} + obj.selected_edc = {id:0,name:''} + obj.selected_account = {id:0,name:''} + }) + var xray = {records:xobj,total:xobj.length} + context.commit("update_types",xray) + context.commit("update_disable_btn_pay",'Y') + console.log(context.state.types) + context.commit("update_last_payments",prm.payments) + context.commit("update_idx",id) + context.commit("update_total_payment",0) + context.commit("update_paynumber","Pembayaran nomor "+xnumber+" telah berhasil") + context.commit("update_dialog_pay_success",true) + context.commit("update_in_saving", false) + + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + }, + async delete_note(context,prm) { + context.commit("update_lookup_status",1) + try { + prm.token = one_token() + let resp= await api.delete_note(prm) + if (resp.status != "OK") { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",resp.message) + } else { + context.commit("update_lookup_status",2) + context.commit("update_lookup_error_message","") + let xmsg = "Nota nomor "+prm.nota.note_number+" telah dihapus" + context.commit("update_msg_delete",xmsg) + context.commit("update_note_delete",'') + context.commit("update_nota_delete",{}) + } + } catch(e) { + context.commit("update_lookup_status",3) + context.commit("update_lookup_error_message",e.message ) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-supplier-payment-v4/store.js b/test/vuex/acc-one-supplier-payment-v4/store.js new file mode 100644 index 0000000..b24b8ff --- /dev/null +++ b/test/vuex/acc-one-supplier-payment-v4/store.js @@ -0,0 +1,31 @@ +// State +// data ... +// Mutations +// +// +// Actions +import bill from "./modules/bill.js"; +import paymentnew from "./modules/paymentnew.js"; +import paymentmanual from "./modules/paymentmanual.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + bill: bill, + paymentnew:paymentnew, + paymentmanual: paymentmanual, + system:system + }, + state: { + tab_selected: 'pasien-dokter' + }, + mutations: { + change_tab(state, ntab) { + state.tab_selected = ntab + } + }, + actions: { + change_tab(context, ntab) { + context.commit('change_tab', ntab) + } + } +}); \ No newline at end of file diff --git a/test/vuex/acc-one-surat-jalan/api/api.js b/test/vuex/acc-one-surat-jalan/api/api.js new file mode 100644 index 0000000..f0e0b3b --- /dev/null +++ b/test/vuex/acc-one-surat-jalan/api/api.js @@ -0,0 +1,261 @@ +const URL = "/one-api/mockup/purchase/suratjalan/SuratJalan/"; + +/* QUERY */ + +export async function lookupEkpedisi(params) { + try { + var response = await axios.post(URL + 'LookupEkspedisi', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function lookupEkpedisiStaff(params) { + try { + var response = await axios.post(URL + 'LookupEkspedisiStaff', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function GetTFDataDetail(params) { + try { + var response = await axios.post(URL + 'LookupSuratJalanDetail', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function ListingSuratJalan(params) { + try { + var response = await axios.post(URL + 'LookupListSuratJalan', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function ListingBranch(params) { + try { + var response = await axios.post(URL + 'LookupListBranch', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function CheckPeriode(params) { + try { + var response = await axios.post(URL + 'CheckPeriode', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function lookupTransferRequest(params) { + try { + var response = await axios.post(URL + 'LookupTransferRequest', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function lookupTransferRequestDetail(params) { + try { + var response = await axios.post(URL + 'LookupTransferRequestDetail', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +/* MUTATIONS */ + +export async function createSuratJalan(params) { + try { + var response = await axios.post(URL + 'CreateSuratJalan', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function updateSuratJalan(params) { + try { + var response = await axios.post(URL + 'UpdateSuratJalan', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function konfirmSuratJalan(params) { + try { + var response = await axios.post(URL + 'KonfirmSuratJalan', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function deleteSuratJalan(params) { + try { + var response = await axios.post(URL + 'DeleteSuratJalan', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function GenerateJurnal(params) { + try { + var response = await axios.post(URL + 'GenerateJurnal', params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-surat-jalan/components/form.vue b/test/vuex/acc-one-surat-jalan/components/form.vue new file mode 100644 index 0000000..ae4f033 --- /dev/null +++ b/test/vuex/acc-one-surat-jalan/components/form.vue @@ -0,0 +1,349 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-surat-jalan/components/listing.vue b/test/vuex/acc-one-surat-jalan/components/listing.vue new file mode 100644 index 0000000..b5c0630 --- /dev/null +++ b/test/vuex/acc-one-surat-jalan/components/listing.vue @@ -0,0 +1,296 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-surat-jalan/index.php b/test/vuex/acc-one-surat-jalan/index.php new file mode 100644 index 0000000..712d602 --- /dev/null +++ b/test/vuex/acc-one-surat-jalan/index.php @@ -0,0 +1,65 @@ + + + + + + + + + + ACCONE | SURAT JALAN + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-surat-jalan/modules/suratjalan.js b/test/vuex/acc-one-surat-jalan/modules/suratjalan.js new file mode 100644 index 0000000..1960343 --- /dev/null +++ b/test/vuex/acc-one-surat-jalan/modules/suratjalan.js @@ -0,0 +1,471 @@ +import * as api from "../api/api.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + f_startdate: new Date().toISOString().substr(0, 10), + f_enddate: new Date().toISOString().substr(0, 10), + f_cabang: { M_BranchCode: "ALL", M_BranchName: "SEMUA" }, + f_status: "All", + f_search: "", + + l_suratjalan: {}, + l_cabang: [], + l_status: ["All", "Draft", "Process", "Completed"], + paginat: 1, + + l_tfrequest: [], + l_ekspedisi: [], + l_staff: [], + + s_suratjalan: { + SuratJalanID: 0, + i_tftype: "", + i_tfrequest: {}, + i_isInternal: "", + i_ekspedisi: {}, + i_staff: {}, + i_phone: "", + i_notes: "", + i_status: "BARU", + i_date: new Date().toISOString().substr(0, 10), + detail: [] + }, + d_page: 1, + + snackbar: { + isOpen: false, + color: "error", + message: "" + } + }, + mutations: { + update_f_startdate(state, data) { + state.f_startdate = data + }, + update_f_enddate(state, data) { + state.f_enddate = data + }, + update_f_cabang(state, data) { + state.f_cabang = data + }, + update_f_status(state, data) { + state.f_status = data + }, + update_f_search(state, data) { + state.f_search = data + }, + update_l_suratjalan(state, data) { + state.l_suratjalan = data + }, + update_l_cabang(state, data) { + state.l_cabang = data + }, + update_l_tfrequest(state, data) { + state.l_tfrequest = data + }, + update_l_ekspedisi(state, data) { + state.l_ekspedisi = data + }, + update_l_staff(state, data) { + state.l_staff = data + }, + update_paginat(state, data) { + state.paginat = data + }, + update_s_suratjalan(state, data) { + state.s_suratjalan = data + }, + update_d_page(state, data) { + state.d_page = data + }, + update_snackbar(state, data) { + state.snackbar = data + } + }, + actions: { + /* QUERY */ + async getBranches(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID + } + let resp = await api.ListingBranch(params) + if (resp.status != "OK") { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + let data = resp.data.records + let all = { + M_BranchCode: "ALL", + M_BranchName: "SEMUA" + } + data.unshift(all) + + context.commit("update_l_cabang", data) + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async listingSuratJalan(context) { + try { + let param = { + token: one_token(), + startdate: context.state.f_startdate, + enddate: context.state.f_enddate, + branchcode: context.state.f_cabang.M_BranchCode, + status: context.state.f_status, + currpage: context.state.paginat + } + let resp = await api.ListingSuratJalan(param) + if (resp.status != 'OK') { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + let suratjalan = { + records: resp.data.records, + total: parseInt(resp.data.total) + } + context.commit("update_l_suratjalan", suratjalan); + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async listingEkspedisi(context) { + try { + let param = { + expdName: "", + isInternal: context.state.s_suratjalan.i_isInternal == 'Internal' ? "Y" : "N", + token: one_token() + } + let resp = await api.lookupEkpedisi(param) + if (resp.status != "OK") { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + context.commit("update_l_ekspedisi", resp.data.records) + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async listingEkspedisiStaff(context) { + try { + let param = { + expID: context.state.s_suratjalan.i_ekspedisi.ExpeditionID, + staffName: "", + token: one_token() + } + let resp = await api.lookupEkpedisiStaff(param) + if (resp.status != "OK") { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + context.commit("update_l_staff", resp.data.records) + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async listingTransferRequest(context) { + try { + let param = { + type: context.state.s_suratjalan.i_tftype, + TFnum: "", + token: one_token() + } + const resp = await api.lookupTransferRequest(param) + if (resp.status != 'OK') { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + context.commit("update_l_tfrequest", resp.data.records) + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async listingTFdetail(context) { + try { + let param = { + TGoodID: context.state.s_suratjalan.i_tfrequest.T_GoodsTransferID, + token: one_token() + } + const resp = await api.lookupTransferRequestDetail(param) + if (resp.status != 'OK') { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + let data = context.state.s_suratjalan + data.detail = resp.data.records + context.commit("update_s_suratjalan", data) + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async mapDetailSuratJalan(context, param) { + try { + param.token = one_token() + + const resp = await api.GetTFDataDetail(param) + if (resp.status != 'OK') { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + const data = resp.data.records + let suratjalan = context.state.s_suratjalan + + suratjalan.i_isInternal = "Internal" + if (data.ExpeditionIsInternal != 'Y') { + suratjalan.i_isInternal = "Eksternal" + } + + let ekspedisi = { + ExpeditionID: data.ExpeditionID, + ExpeditionIsInternal: data.ExpeditionIsInternal, + ExpeditionName: data.ExpeditionName + } + suratjalan.i_ekspedisi = ekspedisi + + let staff = { + ExpeditionStaffID: data.ExpeditionStaffID, + ExpeditionStaffMobile: data.ExpeditionStaffMobile, + ExpeditionStaffName: data.ExpeditionStaffName + } + suratjalan.i_staff = staff + + let transfereq = { + T_GoodsTransferID: data.T_GoodsTransferID, + T_GoodsTransferNum: data.T_GoodsTransferNum, + T_GoodsTransferType: data.T_GoodsTransferType, + T_GoodsTransferDate: data.T_GoodsTransferDate + } + suratjalan.i_tfrequest = transfereq + + suratjalan.i_tftype = data.T_GoodsTransferType == 'P' ? 'Persediaan' : 'Non Persediaan' + suratjalan.i_phone = data.ExpeditionStaffMobile + suratjalan.i_notes = data.SuratJalanNote + suratjalan.i_date = data.SuratJalanDate + suratjalan.i_status = data.SuratJalanStatus + suratjalan.detail = data.detail + suratjalan.SuratJalanID = data.SuratJalanID + suratjalan.SuratJalanNumber = data.SuratJalanNumber + + await context.commit("update_s_suratjalan", suratjalan) + await context.dispatch("listingEkspedisi") + await context.dispatch("listingEkspedisiStaff") + await context.dispatch("listingTransferRequest") + let tfreq = context.state.l_tfrequest + tfreq.push(transfereq) + context.commit("update_l_tfrequest", tfreq) + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async newForm(context) { + try { + let param = { + SuratJalanID: 0, + i_tftype: "", + i_tfrequest: {}, + i_isInternal: "", + i_ekspedisi: {}, + i_staff: {}, + i_phone: "", + i_notes: "", + i_status: "BARU", + i_date: new Date().toISOString().substr(0, 10), + detail: [] + } + + context.commit("update_s_suratjalan", param) + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, Reset Form"} + context.commit("update_snackbar", x) + } + }, + + /* MUTATIONS */ + async createSuratJalan(context) { + try { + const suratjalan = context.state.s_suratjalan + let sjdetail = [] + suratjalan.detail.forEach(element => { + let sjd = { + PRFlagID: element.PRFlagID, + TGDetailID: element.TGDetailID, + ItemID: element.M_ItemID, + Qty: element.Quantity, + ItemUnitID: element.ItemUnitID + } + sjdetail.push(sjd) + }); + + let param = { + SJdate: suratjalan.i_date, + SJnote: suratjalan.i_notes, + TFtype: suratjalan.i_tftype, + TGoodID: suratjalan.i_tfrequest.T_GoodsTransferID, + TGoodNum: suratjalan.i_tfrequest.T_GoodsTransferNum, + EkspedisiID: suratjalan.i_ekspedisi.ExpeditionID, + EkspedisiStaffID: suratjalan.i_staff.ExpeditionStaffID, + EkspedisiStaffHP: suratjalan.i_phone, + SJstatus: suratjalan.i_status == 'BARU' ? 'Draft' : suratjalan.i_status, + detail: sjdetail, + token: one_token() + } + + const resp = await api.createSuratJalan(param) + if (resp.status != 'OK') { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + await context.dispatch("newForm") + await context.dispatch("listingSuratJalan") + + let x = { isOpen: true, color: "success", message: "Success" } + context.commit("update_snackbar", x) + } + + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async updateSuratJalan(context) { + try { + const suratjalan = context.state.s_suratjalan + let sjdetail = [] + + suratjalan.detail.forEach(element => { + let sjd = { + PRFlagID: element.PRFlagID, + TGDetailID: element.TGDetailID, + ItemID: element.M_ItemID, + Qty: element.Quantity, + ItemUnitID: element.ItemUnitID + } + sjdetail.push(sjd) + }); + + let param = { + SJID: suratjalan.SuratJalanID, + SJdate: suratjalan.i_date, + SJnote: suratjalan.i_notes, + TFtype: suratjalan.i_tftype, + TGoodID: suratjalan.i_tfrequest.T_GoodsTransferID, + TGoodNum: suratjalan.i_tfrequest.T_GoodsTransferNum, + EkspedisiID: suratjalan.i_ekspedisi.ExpeditionID, + EkspedisiStaffID: suratjalan.i_staff.ExpeditionStaffID, + EkspedisiStaffHP: suratjalan.i_phone, + SJstatus: suratjalan.i_status == 'BARU' ? 'Draft' : suratjalan.i_status, + detail: sjdetail, + token: one_token() + } + + const resp = await api.updateSuratJalan(param) + if (resp.status != "OK") { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + await context.dispatch("newForm") + await context.dispatch("listingSuratJalan") + + let x = { isOpen: true, color: "success", message: "Success" } + context.commit("update_snackbar", x) + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + async deleteSuratJalan(context, param) { + try { + param.token = one_token() + let resp = await api.deleteSuratJalan(param) + if (resp.status != "OK") { + let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + context.commit("update_snackbar", x) + } else { + await context.dispatch("newForm") + await context.dispatch("listingSuratJalan") + + let x = { isOpen: true, color: "success", message: "Success" } + context.commit("update_snackbar", x) + } + } catch (error) { + let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + context.commit("update_snackbar", x) + } + }, + // async generateJurnal(context, param) { + // try { + // let listsj = context.state.l_suratjalan.records + // let selec = listsj.filter( sj => sj.SuratJalanNumber === param.SuratJalanNumber)[0] + + // let per = { + // date: param.SuratJalanDate, + // token: one_token() + // } + + // let resp = await api.CheckPeriode(per) + // if (resp.status != "OK") { + // let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + // context.commit("update_snackbar", x) + // } else { + // let paar = { + // M_BranchCode: selec.M_BranchCode, + // SuratJalanDate: param.SuratJalanDate, + // SuratJalanID: param.SuratJalanID, + // token: one_token() + // } + // let generate = await api.GenerateJurnal(paar) + // if (generate.status != "OK") { + // let x = { isOpen: true, color: "error", message: "Gagal, " + generate.message } + // context.commit("update_snackbar", x) + // } else { + // context.dispatch("konfirmasiSuratJalan", { + // SJalanID: param.SuratJalanID, + // TGoodID: selec.SuratJalanT_GoodsTransferID, + // detail: param.detail + // }) + // } + // } + // } catch (error) { + // let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + // context.commit("update_snackbar", x) + // } + // }, + // async konfirmasiSuratJalan(context, param) { + // try { + // param.token = one_token() + // let resp = await api.konfirmSuratJalan(param) + // if (resp.status != "OK") { + // let x = { isOpen: true, color: "error", message: "Gagal, " + resp.message } + // context.commit("update_snackbar", x) + // } else { + // await context.dispatch("listingSuratJalan") + + // let x = { isOpen: true, color: "success", message: "Success" } + // context.commit("update_snackbar", x) + // } + // } catch (error) { + // let x = { isOpen: true, color: "error", message: "Gagal, " + error.message } + // context.commit("update_snackbar", x) + // } + // }, + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-surat-jalan/store.js b/test/vuex/acc-one-surat-jalan/store.js new file mode 100644 index 0000000..aff8436 --- /dev/null +++ b/test/vuex/acc-one-surat-jalan/store.js @@ -0,0 +1,11 @@ +import system from "../../../apps/modules/system/system.js" +import suratjalan from "./modules/suratjalan.js"; +export const store = new Vuex.Store({ + modules: { + system: system, + suratjalan: suratjalan + }, + state: {}, + mutations: {}, + actions: {} +}); \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/api/nonpersediaan_api.js b/test/vuex/acc-one-transfer-req/api/nonpersediaan_api.js new file mode 100644 index 0000000..65b872b --- /dev/null +++ b/test/vuex/acc-one-transfer-req/api/nonpersediaan_api.js @@ -0,0 +1,192 @@ +const URL = "/one-api/mockup/purchase/transfer/TransferRequestNP/"; +const URL_SJ = "/one-api/mockup/purchase/suratjalan/SuratJalan/"; + +export async function getBranches(params) { + try { + var resp = await axios.post(URL + "getBranches", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getDivision(params) { + try { + var resp = await axios.post(URL + "getDivision", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function search(params) { + try { + var resp = await axios.post(URL + "search", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function createTfRequest(params) { + try { + var resp = await axios.post(URL + "createTfRequest", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function updateTfRequest(params) { + try { + var resp = await axios.post(URL + "updateTfRequest", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function deleteTfRequest(params) { + try { + var resp = await axios.post(URL + "deleteTfRequest", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getListDetail(params) { + try { + var resp = await axios.post(URL + "getListDetail", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getDraftDetail(params) { + try { + var resp = await axios.post(URL + "getDraftDetail", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getListStock(params) { + try { + var resp = await axios.post(URL + "getListStock", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getUserLevel(params) { + try { + var resp = await axios.post(URL + "getUserLevel", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/api/persediaan_api.js b/test/vuex/acc-one-transfer-req/api/persediaan_api.js new file mode 100644 index 0000000..5c93a87 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/api/persediaan_api.js @@ -0,0 +1,260 @@ +const URL = "/one-api/mockup/purchase/transfer/"; +const URL_SJ = "/one-api/mockup/purchase/suratjalan/SuratJalan/"; + +export async function getBranches(params) { + try { + var response = await axios.post(URL + "TransferRequest/getBranches", params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + } + } +} + +export async function getStatus(params) { + try { + var response = await axios.post(URL + "TransferRequest/getStatus", params); + + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + } + } +} + +export async function search(params) { + try { + var response = await axios.post(URL + "TransferRequest/search", params); + + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + } + } +} + +export async function saveRequest(params) { + try { + var response = await axios.post(URL + "TransferRequest/createTfRequest", params); + + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + } + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + } + } +} + +export async function getListDetail(params) { + try { + var response = await axios.post(URL + "TransferRequest/getListDetail", params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.message + } + } + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function deleteTransfer(params) { + try { + var response = await axios.post(URL + "TransferRequest/deleteTFRequest", params) + if (response.status !== 200) { + return { + status: "ERR", + message: response.message + } + } + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function updateTransfer(params) { + try { + var resp = await axios.post(URL + "TransferRequest/updateTfRequest", params) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getDraftDetail(params) { + try { + var resp = await axios.post(URL + "TransferRequest/getDraftDetail", params) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function createSuratJalanFromTF(params) { + try { + var resp = await axios.post(URL_SJ + "CreateSuratJalanFromTF", params) + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.message + } + } + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getItemBatchListing(params) { + try { + var resp = await axios.post(URL + "TransferRequest/getItemBatchListing", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.message + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getUnpackItemBatchListing(params) { + try { + var resp = await axios.post(URL + "TransferRequest/getUnpackItemBatchListing", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.message + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function unpackingStock(params){ + try { + var resp = await axios.post(URL + "TransferRequest/unpackingStock", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.message + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} + +export async function getUserLevel(params){ + try { + var resp = await axios.post(URL + "TransferRequest/getUserLevel", params); + if (resp.status !== 200) { + return { + status: "ERR", + message: resp.message + } + } + + let data = resp.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/dialogBatchNonPersediaan.vue b/test/vuex/acc-one-transfer-req/components/dialogBatchNonPersediaan.vue new file mode 100644 index 0000000..54ae08f --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/dialogBatchNonPersediaan.vue @@ -0,0 +1,165 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/dialogBatchPersediaan.vue b/test/vuex/acc-one-transfer-req/components/dialogBatchPersediaan.vue new file mode 100644 index 0000000..a1a89c5 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/dialogBatchPersediaan.vue @@ -0,0 +1,174 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/dialogDetailNonPersediaan.vue b/test/vuex/acc-one-transfer-req/components/dialogDetailNonPersediaan.vue new file mode 100644 index 0000000..7c3b8b3 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/dialogDetailNonPersediaan.vue @@ -0,0 +1,152 @@ + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/dialogDetailPersediaan.vue b/test/vuex/acc-one-transfer-req/components/dialogDetailPersediaan.vue new file mode 100644 index 0000000..0ffea4d --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/dialogDetailPersediaan.vue @@ -0,0 +1,224 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/dialogUnpackPersediaan.vue b/test/vuex/acc-one-transfer-req/components/dialogUnpackPersediaan.vue new file mode 100644 index 0000000..868ee5f --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/dialogUnpackPersediaan.vue @@ -0,0 +1,168 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/formNonPersediaanTF.vue b/test/vuex/acc-one-transfer-req/components/formNonPersediaanTF.vue new file mode 100644 index 0000000..5ae392a --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/formNonPersediaanTF.vue @@ -0,0 +1,515 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/formPersediaanTF.vue b/test/vuex/acc-one-transfer-req/components/formPersediaanTF.vue new file mode 100644 index 0000000..ca5af68 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/formPersediaanTF.vue @@ -0,0 +1,524 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/listingNonPersediaanTF.vue b/test/vuex/acc-one-transfer-req/components/listingNonPersediaanTF.vue new file mode 100644 index 0000000..c4336c3 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/listingNonPersediaanTF.vue @@ -0,0 +1,320 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/listingPersediaanTF.vue b/test/vuex/acc-one-transfer-req/components/listingPersediaanTF.vue new file mode 100644 index 0000000..0045eac --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/listingPersediaanTF.vue @@ -0,0 +1,319 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/components/mainlayout.vue b/test/vuex/acc-one-transfer-req/components/mainlayout.vue new file mode 100644 index 0000000..c435a89 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/components/mainlayout.vue @@ -0,0 +1,115 @@ + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/index.php b/test/vuex/acc-one-transfer-req/index.php new file mode 100644 index 0000000..9b46eb5 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/index.php @@ -0,0 +1,61 @@ + + + + + + + + + + + Transfer Reg ke Cab + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/modules/np_data.js b/test/vuex/acc-one-transfer-req/modules/np_data.js new file mode 100644 index 0000000..b6dccd4 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/modules/np_data.js @@ -0,0 +1,135 @@ +import * as api from "../api/nonpersediaan_api.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + user_level: {}, + filter_sdate: new Date().toISOString().substr(0, 10), + filter_edate: new Date().toISOString().substr(0, 10), + filter_cabang: { + M_BranchID: "0", + M_BranchCode: "All", + M_BranchName: "Semua" + }, + filter_status: "All", + filter_search: "", + listing_cabang: [], + listing_status: [ + "All", + "Draft", + "Verified", + "Process", + "Completed" + ], + + listing_tf_req: { + total: 0, + records: [] + }, + listing_tf_page: 1, + selected_tf: {} + }, + mutations: { + update_filter_sdate(state, data) { + state.filter_sdate = data + }, + update_filter_edate(state, data) { + state.filter_edate = data + }, + update_filter_cabang(state, data) { + state.filter_cabang = data + }, + update_filter_status(state, data) { + state.filter_status = data + }, + update_filter_search(state, data) { + state.filter_search = data + }, + update_listing_cabang(state, data) { + state.listing_cabang = data + }, + update_listing_status(state, data) { + state.listing_status = data + }, + update_listing_tf_req(state, data) { + state.listing_tf_req = data + }, + update_listing_tf_page(state, data) { + state.listing_tf_page = data + }, + update_selected_tf(state, data) { + state.selected_tf = data + }, + update_user_level(state, data) { + state.user_level = data + } + }, + actions: { + async getBranches(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID + } + + let resp = await api.getBranches(params); + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + let all = [ + { + M_BranchID: "0", + M_BranchCode: "All", + M_BranchName: "Semua" + } + ] + all.concat(resp.data.records) + context.commit("update_listing_cabang", all) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async cariTF(context) { + try { + let params = { + token: one_token(), + startDate: context.state.filter_sdate, + endDate: context.state.filter_edate, + M_BranchCode: context.state.filter_cabang.M_BranchCode, + StatusName: context.state.filter_status, + currentPage: context.state.listing_tf_page, + search: context.state.filter_search + } + + let resp = await api.search(params) + if (resp.status != "OK") { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else [ + context.commit("update_listing_tf_req", resp.data) + ] + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async userLevel(context) { + try { + let resp = await api.getUserLevel({token: one_token()}) + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + context.commit("update_user_level", resp.data) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/modules/np_form.js b/test/vuex/acc-one-transfer-req/modules/np_form.js new file mode 100644 index 0000000..de02e04 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/modules/np_form.js @@ -0,0 +1,307 @@ +import * as api from "../api/nonpersediaan_api.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + form_transfer_date: new Date().toISOString().substr(0, 10), + form_cabang: {}, + form_divisi: {}, + form_catatan: "", + form_detail: [], + + dialog_detailform: false, + list_cabangform: [], + list_divisiform: [], + list_detailform: { + total: 0, + records: [] + }, + list_detailform_page: 1, + type_act: 'BARU', + is_verif: 'Draft', + + buffer_detailitem: {}, + dialog_batchitem: false, + list_barnote: {}, + form_barnote: [], + edit_qty: 'Eqty', + act_verif: '' + }, + mutations: { + update_form_transfer_date(state, data) { + state.form_transfer_date = data + }, + update_form_cabang(state, data) { + state.form_cabang = data + }, + update_form_divisi(state, data) { + state.form_divisi = data + }, + update_form_catatan(state, data) { + state.form_catatan = data + }, + update_form_detail(state, data) { + state.form_detail = data + }, + update_dialog_detailform(state, data) { + state.dialog_detailform = data + }, + update_list_cabangform(state, data) { + state.list_cabangform = data + }, + update_list_divisiform(state, data) { + state.list_divisiform = data + }, + update_list_detailform(state, data) { + state.list_detailform = data + }, + update_list_detailform_page(state, data) { + state.list_detailform_page = data + }, + update_type_act(state, data) { + state.type_act = data + }, + update_is_verif(state, data) { + state.is_verif = data + }, + update_buffer_detailitem(state, data) { + state.buffer_detailitem = data + }, + update_list_barnote(state, data) { + state.list_barnote = data + }, + update_dialog_batchitem(state, data) { + state.dialog_batchitem = data + }, + update_form_barnote(state, data) { + state.form_barnote = data + }, + update_edit_qty(state, data) { + state.edit_qty = data + }, + update_act_verif(state, data) { + state.act_verif = data + } + }, + actions: { + async newForm(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID + } + let resp = await api.getBranches(params) + if (resp.status != "OK") { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + context.commit("update_type_act", "BARU") + context.commit("update_list_cabangform", resp.data.records) + context.dispatch("getDivisi", {}) + + context.commit("update_form_transfer_date", new Date().toISOString().substr(0, 10)) + context.commit("update_form_cabang", { }) + context.commit("update_form_divisi", { }) + context.commit("update_form_catatan", "") + context.commit("update_list_detailform", {total: 0, records: []}) + context.commit("update_is_verif", 'Draft') + context.commit("update_form_detail", [ ]) + context.commit("np_data/update_selected_tf", { }, { root: true }) + } + + + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async getDivisi(context) { + try { + let params = {token: one_token()} + + let resp = await api.getDivision(params); + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + context.commit("update_list_divisiform", resp.data) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async getListItemDetail(context) { + try { + let params = { + token: one_token(), + currpage: context.state.list_detailform_page, + regionalid: context.state.user.S_RegionalID, + branchcodedestin: context.state.form_cabang.M_BranchCode, + branchIDorigin: context.state.user.M_BranchID, + divisionID: context.state.form_divisi.DivisionID + } + + let resp = await api.getListDetail(params) + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + const current_detail = context.state.form_detail + if (current_detail.length == 0) { + context.commit("update_list_detailform", resp.data) + } else { + const inserted = resp.data.records.filter(item => !current_detail.some(obj => obj.PurchaseRequestFlagID == item.PurchaseRequestFlagID)) + let data = { + records: inserted, + total: parseInt(resp.data.total) + } + context.commit("update_list_detailform", data) + } + } + + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async createTFReq(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID, + M_BranchCode: context.state.form_cabang.M_BranchCode, + DivisionID: context.state.form_divisi.DivisionID, + GoodsTfNotes: context.state.form_catatan, + GoodsTfDate: context.state.form_transfer_date, + GoodsTfStatus: context.state.is_verif, + detail: context.state.form_detail + } + + let resp = await api.createTfRequest(params); + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + // generate surat jalan atau nggak? + + context.dispatch("newForm") + context.dispatch("np_data/cariTF", { }, { root: true }) + let snac = { isOpen: true, color: "success", msg: "Success" } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async updateTFReq(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID, + M_BranchCode: context.state.form_cabang.M_BranchCode, + DivisionID: context.state.form_divisi.DivisionID, + GoodsTfID: context.rootState.np_data.selected_tf.T_GoodsTransferID, + GoodsTfNum: context.rootState.np_data.selected_tf.T_GoodsTransferNum, + GoodsTfNotes: context.state.form_catatan, + GoodsTfDate: context.state.form_transfer_date, + GoodsTfStatus: context.state.is_verif, + editqty: context.state.edit_qty, + actverif: context.state.act_verif, + detail: context.state.form_detail + } + + let resp = await api.updateTfRequest(params); + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + // generate surat jalan atau nggak? + + context.dispatch("newForm") + context.dispatch("np_data/cariTF", { }, { root: true }) + let snac = { isOpen: true, color: "success", msg: "Success" } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async deleteTFReq(context, params) { + try { + params.token = one_token() + let resp = await api.deleteTfRequest(params); + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + context.dispatch("newForm") + context.dispatch("p_data/cariTF", { }, { root: true }) + + let snac = { isOpen: true, color: "success", msg: resp.data} + context.commit("p_data/update_snackbar", snac, { root: true }) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async displayDetail(context) { + try { + let detail = context.rootState.np_data.selected_tf + context.commit("update_form_transfer_date", detail.T_GoodsTransferDate) + context.commit("update_form_catatan", detail.T_GoodsTransferNotes) + context.commit("update_is_verif", detail.T_GoodsTransferStatus) + + context.commit("update_form_cabang", { + M_BranchID: detail.M_BranchID, + M_BranchCode: detail.M_BranchCode, + M_BranchName: detail.M_BranchName + }) + + context.commit("update_form_divisi", { + DivisionID: detail.T_GoodsTransferDivisionID, + DivisionCode: detail.DivisionCode, + DivisionName: detail.DivisionName + }) + + let params = { + token: one_token(), + goodTfID: detail.T_GoodsTransferID + } + const resp = await api.getDraftDetail(params) + if (resp.status !== 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + const draft = resp.data.records + context.commit("update_form_detail", draft); + } + + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async getListStock(context, params) { + try { + params.token = one_token() + params.regionalid = context.state.user.S_RegionalID + + const resp = await api.getListStock(params) + if (resp.status !== 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + context.commit("update_list_barnote", resp.data) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/modules/p_data.js b/test/vuex/acc-one-transfer-req/modules/p_data.js new file mode 100644 index 0000000..249af9b --- /dev/null +++ b/test/vuex/acc-one-transfer-req/modules/p_data.js @@ -0,0 +1,169 @@ +import * as api from "../api/persediaan_api.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + user_level: {}, + filter_sdate: new Date().toISOString().substr(0, 10), + filter_edate: new Date().toISOString().substr(0, 10), + filter_cabang: { + M_BranchID: "0", + M_BranchCode: "All", + M_BranchName: "Semua" + }, + filter_status: "All", + filter_search: "", + listing_cabang: [], + listing_status: [ + "All", + "Draft", + "Pending", + "Verified", + "Approved", + "Process", + "Completed" + ], + + listing_tf_req: { + total: 0, + records: [] + }, + listing_tf_page: 1, + selected_tf: {}, + + snackbar: { + isOpen: false, + color: "error", + msg: "" + } + }, + mutations: { + update_filter_sdate(state, data) { + state.filter_sdate = data + }, + update_filter_edate(state, data) { + state.filter_edate = data + }, + update_filter_cabang(state, data) { + state.filter_cabang = data + }, + update_filter_status(state, data) { + state.filter_status = data + }, + update_filter_search(state, data) { + state.filter_search = data + }, + update_listing_cabang(state, data) { + state.listing_cabang = data + }, + update_listing_status(state, data) { + state.listing_status = data + }, + update_listing_tf_req(state, data) { + state.listing_tf_req = data + }, + update_listing_tf_page(state, data) { + state.listing_tf_page = data + }, + update_selected_tf(state, data) { + state.selected_tf = data + }, + update_snackbar(state, data) { + state.snackbar = data + }, + update_user_level(state, data) { + state.user_level = data + } + }, + actions: { + async getBranches(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID + } + let resp = await api.getBranches(params) + if (resp.status != "OK") { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", snac) + } else { + let all = [ + { + M_BranchID: "0", + M_BranchCode: "All", + M_BranchName: "Semua" + } + ] + + all = all.concat(resp.data.records) + context.commit("update_listing_cabang", all) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", snac) + } + }, + async cariTF(context) { + try { + let params = { + token: one_token(), + startDate: context.state.filter_sdate, + endDate: context.state.filter_edate, + M_BranchCode: context.state.filter_cabang.M_BranchCode, + StatusName: context.state.filter_status, + currentPage: context.state.listing_tf_page, + search: context.state.filter_search + } + + let resp = await api.search(params) + if (resp.status != "OK") { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", snac) + } else { + let data = { + records: resp.data.records, + total: parseInt(resp.data.total) + } + context.commit("update_listing_tf_req", data) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", snac) + } + }, + async deleteTF(context, params) { + try { + params.token = one_token() + let resp = await api.deleteTransfer(params) + if (resp.status != "OK") { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", snac) + } else { + context.dispatch("p_form/newForm", { },{ root: true }) + context.dispatch("cariTF") + + let snac = { isOpen: true, color: "success", msg: "Sukses"} + context.commit("update_snackbar", snac) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", snac) + } + }, + async userlevel(context) { + try { + let resp = await api.getUserLevel({token: one_token()}) + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("update_snackbar", snac) + } else { + context.commit("update_user_level", resp.data); + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("update_snackbar", snac) + } + } + }, +} \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/modules/p_form.js b/test/vuex/acc-one-transfer-req/modules/p_form.js new file mode 100644 index 0000000..6ec5f98 --- /dev/null +++ b/test/vuex/acc-one-transfer-req/modules/p_form.js @@ -0,0 +1,316 @@ +import * as api from "../api/persediaan_api.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + form_transfer_date: new Date().toISOString().substr(0, 10), + form_cabang: {}, + form_catatan: "", + form_detail: [], + + dialog_detailform: false, + list_cabangform: [], + list_detailform: { + total: 0, + records: [] + }, + list_detailform_page: 1, + type_act: 'BARU', + is_verif: 'Draft', + + buffer_detailitem: {}, + list_batchitemform: {}, + dialog_batchitem: false, + form_batchitem: [], + + dialog_unpackform: false, + buffer_itemrequestedunpack: {}, + list_batchitemunpack: [], + selected_batchitemunpack: {}, + edit_qty: 'Eqty', + act_verif: '' + }, + mutations: { + update_form_transfer_date(state, data) { + state.form_transfer_date = data + }, + update_form_cabang(state, data) { + state.form_cabang = data + }, + update_form_catatan(state, data) { + state.form_catatan = data + }, + update_form_detail(state, data) { + state.form_detail = data + }, + update_dialog_detailform(state, data) { + state.dialog_detailform = data + }, + update_list_cabangform(state, data) { + state.list_cabangform = data + }, + update_list_detailform(state, data) { + state.list_detailform = data + }, + update_list_detailform_page(state, data) { + state.list_detailform_page = data + }, + update_type_act(state, data) { + state.type_act = data + }, + update_is_verif(state, data) { + state.is_verif = data + }, + update_buffer_detailitem(state, data) { + state.buffer_detailitem = data + }, + update_list_batchitemform(state, data) { + state.list_batchitemform = data + }, + update_dialog_batchitem(state, data) { + state.dialog_batchitem = data + }, + update_form_batchitem(state, data) { + state.form_batchitem = data + }, + update_dialog_unpackform(state, data){ + state.dialog_unpackform = data + }, + update_buffer_itemrequestedunpack(state, data){ + state.buffer_itemrequestedunpack = data + }, + update_list_batchitemunpack(state, data){ + state.list_batchitemunpack = data + }, + update_selected_batchitemunpack(state, data){ + state.selected_batchitemunpack = data + }, + update_edit_qty(state, data) { + state.edit_qty = data + }, + update_act_verif(state, data) { + state.act_verif = data + } + }, + actions: { + async newForm(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID + } + let resp = await api.getBranches(params) + if (resp.status != "OK") { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + context.commit("update_type_act", "BARU") + context.commit("update_list_cabangform", resp.data.records) + + context.commit("update_form_cabang", { }) + context.commit("update_form_transfer_date", new Date().toISOString().substr(0, 10)) + context.commit("update_form_catatan", "") + context.commit("update_list_detailform", {total: 0, records: [ ]}) + context.commit("update_is_verif", 'Draft') + context.commit("update_form_detail", [ ]) + context.commit("p_data/update_selected_tf" , {}, { root: true }) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async displayDetail(context) { + try { + let detail = context.rootState.p_data.selected_tf + context.commit("update_form_transfer_date", detail.T_GoodsTransferDate) + context.commit("update_form_catatan", detail.T_GoodsTransferNotes) + context.commit("update_is_verif", detail.T_GoodsTransferStatus) + context.commit("update_form_cabang", { + M_BranchID: detail.M_BranchID, + M_BranchCode: detail.M_BranchCode, + M_BranchName: detail.M_BranchName + }) + + // get list detail item form + let params = { + token: one_token(), + goodTfID: detail.T_GoodsTransferID + } + let resp = await api.getDraftDetail(params); + if (resp.status !== 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + let draft = resp.data.records + context.commit("update_form_detail", draft) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async getListItemDetail(context) { + try { + let params = { + token: one_token(), + currpage: context.state.list_detailform_page, + regionalid: context.state.user.S_RegionalID, + branchcodedestin: context.state.form_cabang.M_BranchCode, + branchIDorigin: context.state.user.M_BranchID + } + + let resp = await api.getListDetail(params) + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + let current_detail = context.state.form_detail + if (current_detail.length == 0) { + context.commit("update_list_detailform", resp.data) + } else { + const inserted = resp.data.records.filter(item => !current_detail.some(obj => obj.PurchaseRequestFlagID == item.PurchaseRequestFlagID)) + let data = { + records: inserted, + total: parseInt(resp.data.total) + } + context.commit("update_list_detailform", data) + } + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async createTFrequest(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID, + M_BranchCode: context.state.form_cabang.M_BranchCode, + GoodsTfNotes: context.state.form_catatan, + GoodsTfDate: context.state.form_transfer_date, + GoodsTfStatus: context.state.is_verif, + detail: context.state.form_detail + } + + let resp = await api.saveRequest(params) + + if (resp.status !== 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + if (params.GoodsTfStatus === 'Verified') { + params.GoodsTfNum = resp.data.records.T_GoodsTransferNum + params.GoodsTfID = resp.data.records.T_GoodsTransferID + params.detail = resp.data.records.detail + } + + context.dispatch("newForm") + context.dispatch("p_data/cariTF", { }, { root: true }) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async updateTFrequest(context) { + try { + let params = { + token: one_token(), + S_RegionalID: context.state.user.S_RegionalID, + M_BranchCode: context.state.form_cabang.M_BranchCode, + GoodsTfID: context.rootState.p_data.selected_tf.T_GoodsTransferID, + GoodsTfNum: context.rootState.p_data.selected_tf.T_GoodsTransferNum, + GoodsTfNotes: context.state.form_catatan, + GoodsTfDate: context.state.form_transfer_date, + GoodsTfStatus: context.state.is_verif, + editqty: context.state.edit_qty, + actverif: context.state.act_verif, + detail: context.state.form_detail + } + + let resp = await api.updateTransfer(params) + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + if (params.GoodsTfStatus === 'Verified') { + params.detail = resp.data.records.detail + } + + context.dispatch("newForm") + context.dispatch("p_data/cariTF", { }, { root: true }) + + if (context.state.edit_qty == 'Eqty') { + var snac = { isOpen: true, color: 'success', msg: 'Success update qty tf request' } + } else { + var snac = { isOpen: true, color: 'success', msg: 'Success update tf request' } + } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async getBatchItemDetail(context, params) { + try { + params.token = one_token() + params.regionalid = context.state.user.S_RegionalID + params.branchid = context.state.user.M_BranchID + + let resp = await api.getItemBatchListing(params) + if (resp.status != 'OK') { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + context.commit("update_list_batchitemform", resp.data) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async getBatchItemUnpackList(context, params){ + try{ + params.token = one_token() + params.regionalid = context.state.user.S_RegionalID + params.branchid = context.state.user.M_BranchID + + let resp = await api.getUnpackItemBatchListing(params) + if (resp.status != 'OK'){ + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + context.commit("update_list_batchitemunpack", resp.data.records) + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + }, + async unpackingStock(context, params){ + try { + params.token = one_token() + + let resp = await api.unpackingStock(params) + + if (resp.status != 'OK'){ + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } else { + let snac = { isOpen: true, color: "success", msg: "Berhasil Unpack Stock"} + context.commit("p_data/update_snackbar", snac, { root: true }) + + // Reload Item Requested List Detail + await context.dispatch("getListItemDetail") + } + } catch (error) { + let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message } + context.commit("p_data/update_snackbar", snac, { root: true }) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/acc-one-transfer-req/store.js b/test/vuex/acc-one-transfer-req/store.js new file mode 100644 index 0000000..14f538e --- /dev/null +++ b/test/vuex/acc-one-transfer-req/store.js @@ -0,0 +1,26 @@ +import system from "../../../apps/modules/system/system.js"; +import np_data from "./modules/np_data.js"; +import np_form from "./modules/np_form.js"; +import p_data from "./modules/p_data.js"; +import p_form from "./modules/p_form.js"; + +export const store = new Vuex.Store({ + modules: { + system: system, + p_data: p_data, + p_form: p_form, + np_data: np_data, + np_form: np_form + }, + state: { + type_transfer: 'P' + }, + mutations: { + update_type_transfer(state, data) { + state.type_transfer = data + } + }, + actions: { + + }, +}); \ No newline at end of file diff --git a/test/vuex/accone-purchase-request-kacab/api/api-manager.js b/test/vuex/accone-purchase-request-kacab/api/api-manager.js new file mode 100644 index 0000000..d479cf5 --- /dev/null +++ b/test/vuex/accone-purchase-request-kacab/api/api-manager.js @@ -0,0 +1,136 @@ +const URL = "/one-api/mockup/purchase/manager/"; + +export async function search(payload) { + try { + var response = await axios.post(URL + "purchaseRequest/search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function searchDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/searchDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function deleteDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/deleteDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function approveRequest(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/approveRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function rejectRequest(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/rejectRequest", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} + +export async function updateDetail(payload) { + try { + var response = await axios.post( + URL + "purchaseRequest/updateDetail", + payload + ); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} diff --git a/test/vuex/accone-purchase-request-kacab/api/prkcab.js b/test/vuex/accone-purchase-request-kacab/api/prkcab.js new file mode 100644 index 0000000..c5e9f11 --- /dev/null +++ b/test/vuex/accone-purchase-request-kacab/api/prkcab.js @@ -0,0 +1,98 @@ +const URL = "/one-api/mockup/purchaserequestkacab/purchaserequestkacab/"; +// https://accone.aplikasi.web.id/one-api/mockup/purchaserequestkacab/purchaserequestkacab/search + +export async function search(payload) { + try { + var response = await axios.post(URL + "search", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function getDetail(payload) { + try { + var response = await axios.post(URL + "getDetail", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function approve(payload) { + try { + var response = await axios.post(URL + "approve", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function updateqty(payload) { + try { + var response = await axios.post(URL + "updateqty", payload); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText, + }; + } + + let data = response.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message, + }; + } +} +export async function approvelevel(params) { + try { + var response = await axios.post(URL + 'getUserApproveLevel', params); + if (response.status !== 200) { + return { + status: "ERR", + message: response.statusText + }; + } + + let data = response.data + return data + } catch (error) { + return { + status: "ERR", + message: error.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/accone-purchase-request-kacab/components/acconeprkacab.vue b/test/vuex/accone-purchase-request-kacab/components/acconeprkacab.vue new file mode 100644 index 0000000..2221bc4 --- /dev/null +++ b/test/vuex/accone-purchase-request-kacab/components/acconeprkacab.vue @@ -0,0 +1,898 @@ + + + + + diff --git a/test/vuex/accone-purchase-request-kacab/components/requestListing.vue b/test/vuex/accone-purchase-request-kacab/components/requestListing.vue new file mode 100644 index 0000000..fbb12bf --- /dev/null +++ b/test/vuex/accone-purchase-request-kacab/components/requestListing.vue @@ -0,0 +1,905 @@ + + + + + diff --git a/test/vuex/accone-purchase-request-kacab/index.php b/test/vuex/accone-purchase-request-kacab/index.php new file mode 100644 index 0000000..3647bc2 --- /dev/null +++ b/test/vuex/accone-purchase-request-kacab/index.php @@ -0,0 +1,68 @@ + + + + + + + + + + + One + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/accone-purchase-request-kacab/modules/manager.js b/test/vuex/accone-purchase-request-kacab/modules/manager.js new file mode 100644 index 0000000..ebcc22b --- /dev/null +++ b/test/vuex/accone-purchase-request-kacab/modules/manager.js @@ -0,0 +1,353 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/api-manager.js"; + +export default { + namespaced: true, + state: { + mainTable: [], + detailTable: [], + countMainTable: 0, + countDetailTable: 0, + mainTableLoadingStatus: 0, + detailTableLoadingStatus: 0, + mainTableErrorMessage: "", + detailTableErrorMessage: "", + mainTableCurrentPage: 1, + mainTableLastId: -1, + + selectedMainTable: {}, + selectedDetailTable: {}, + + statusOptions: [ + { value: 0, title: "All" }, + { value: 2, title: "Pending" }, + { value: 3, title: "Approved" }, + { value: 4, title: "Rejected" }, + { value: 5, title: "Paid" }, + { value: 6, title: "Completed" }, + ], + + menuStartDate: false, + menuEndDate: false, + + dStartDate: new Date().toISOString().substring(0, 10), + dEndDate: new Date().toISOString().substring(0, 10), + fStartDate: moment(new Date()).format("YYYY-MM-DD"), + fEndDate: moment(new Date()).format("YYYY-MM-DD"), + fStatus: 0, + fSearch: "", + + xNote: "", + xAmount: 0, + xPRID: 0, + xPRDID: 0, + xStatus: "", + xDescriptionDetail: "", + + dialogDetail: false, + errMessage: "", + succesMessage: "", + alertError: false, + alertSuccess: false, + errors: [], + }, + mutations: { + updateMainTable(state, val) { + state.mainTable = val; + }, + updateDetailTable(state, val) { + state.detailTable = val; + }, + updateCountMainTable(state, val) { + state.countMainTable = val; + }, + updateCountDetailTable(state, val) { + state.countDetailTable = val; + }, + updateMainTableLoadingStatus(state, val) { + state.mainTableLoadingStatus = val; + }, + updateDetailTableLoadingStatus(state, val) { + state.detailTableLoadingStatus = val; + }, + updateMainTableErrorMessage(state, val) { + state.mainTableErrorMessage = val; + }, + updateDetailTableErrorMessage(state, val) { + state.detailTableErrorMessage = val; + }, + updateMainTableCurrentPage(state, val) { + state.mainTableCurrentPage = val; + }, + updateMainTableLastId(state, val) { + state.mainTableLastId = val; + }, + + updateSelectedMainTable(state, val) { + state.selectedMainTable = val; + }, + updateSelectedDetailTable(state, val) { + state.selectedDetailTable = val; + }, + + updateMenuStartDate(state, val) { + state.menuStartDate = val; + }, + updateMenuEndDate(state, val) { + state.menuEndDate = val; + }, + + updateDStartDate(state, val) { + state.dStartDate = val; + }, + updateDEndDate(state, val) { + state.dEndDate = val; + }, + updateFStartDate(state, val) { + state.fStartDate = val; + }, + updateFEndDate(state, val) { + state.fEndDate = val; + }, + updateFStatus(state, val) { + state.fStatus = val; + }, + updateFSearch(state, val) { + state.fSearch = val; + }, + + updateXNote(state, val) { + state.xNote = val; + }, + updateXAmount(state, val) { + state.xAmount = val; + }, + updateXPRID(state, val) { + state.xPRID = val; + }, + updateXPRDID(state, val) { + state.xPRDID = val; + }, + updateXStatus(state, val) { + state.xStatus = val; + }, + updateXDescriptionDetail(state, val) { + state.xDescriptionDetail = val; + }, + + updateDialogDetail(state, val) { + state.dialogDetail = val; + }, + updateErrMessage(state, val) { + state.errMessage = val; + }, + updateSuccessMessage(state, val) { + state.successMessage = val; + }, + updateAlertError(state, val) { + state.alertError = val; + }, + updateAlertSuccess(state, val) { + state.alertSuccess = val; + }, + updateErrors(state, val) { + state.errors = val; + }, + }, + actions: { + async search(context) { + context.commit("updateMainTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + currentPage: context.state.mainTableCurrentPage, + startDate: context.state.fStartDate, + endDate: context.state.fEndDate, + status: context.state.fStatus, + search: context.state.fSearch, + lastId: -1, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", response.message); + } else { + context.commit("updateMainTableLoadingStatus", 2); + context.commit("updateMainTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateMainTable", data.records); + context.commit("updateCountMainTable", data.total); + } + } catch (e) { + context.commit("updateMainTableLoadingStatus", 3); + context.commit("updateMainTableErrorMessage", e.message); + } + }, + async searchDetail(context) { + context.commit("updateDetailTableLoadingStatus", 1); + + try { + var payload = { + token: one_token(), + PRID: context.state.selectedMainTable.PurchaseRequestDirectID, + }; + + let response = await api.searchDetail(payload); + if (response.status != "OK") { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", response.message); + } else { + context.commit("updateDetailTableLoadingStatus", 2); + context.commit("updateDetailTableErrorMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("updateDetailTable", data.records); + context.commit("updateCountDetailTable", data.total); + } + } catch (e) { + context.commit("updateDetailTableLoadingStatus", 3); + context.commit("updateDetailTableErrorMessage", e.message); + } + }, + async updateDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.updateDetail(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + context.commit("updateDialogDetail", false); + var msg = `Request [${payload.PRDDescription}] telah diperbarui`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async rejectRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.rejectRequest(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request [${payload.PRNumber}] sudah ditolak`; + context.commit("updateSuccessMessage", msg); + context.commit("updateSelectedMainTable", {}); + context.commit("updateDetailTable", []); + context.commit("updateSelectedDetailTable", {}); + context.dispatch("search"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async deleteDetail(context, payload) { + try { + payload.token = one_token(); + + let response = await api.deleteDetail(payload); + if (response.status !== "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Request [${payload.PRDDescription}] sudah dihapus`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + async approveRequest(context, payload) { + try { + payload.token = one_token(); + + let response = await api.approveRequest(payload); + if (response.status != "OK") { + context.commit("updateErrMessage", response.message); + context.commit("updateAlertError", true); + } else { + context.commit("updateErrMessage", ""); + let data = { + records: response.data.records, + total: response.data.total, + }; + + if (data.total !== -1) { + context.commit("updateErrors", []); + context.commit("updateAlertSuccess", true); + var msg = `Purchase Request [${payload.PRNumber}] telah diapprove`; + context.commit("updateSuccessMessage", msg); + context.dispatch("search"); + context.commit("updateSelectedMainTable", data.records[0]); + context.dispatch("searchDetail"); + } else { + context.commit("updateErrors", response.data.errors); + } + } + } catch (e) { + context.commit("updateErrMessage", e.message); + context.commit("updateAlertError", true); + } + }, + }, +}; diff --git a/test/vuex/accone-purchase-request-kacab/modules/prkacab.js b/test/vuex/accone-purchase-request-kacab/modules/prkacab.js new file mode 100644 index 0000000..ad8956b --- /dev/null +++ b/test/vuex/accone-purchase-request-kacab/modules/prkacab.js @@ -0,0 +1,358 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR + +import * as api from "../api/prkcab.js"; + +export default { + namespaced: true, + state: { + user: one_user(), + statusOptions: [ + { value: 'All', title: "All" }, + { value: 'Draft', title: "Draft" }, + { value: 'Pending', title: "Pending" }, + { value: 'Approved', title: "Approved" }, + { value: 'Rejected', title: "Rejected" }, + { value: 'Terkirim', title: "Terkirim" }, + { value: 'Partial', title: "Partial" }, + { value: 'Selesai', title: "Selesai" }, + ], + selectedStatus: { value: 'All', title: "All" }, + selectedDate: moment(new Date()).format('YYYY-MM-DD'), + selectedEndDate: moment(new Date()).format('YYYY-MM-DD'), + search: '', + totalPage: 0, + selectedPage: 1, + loading: false, + prList: [], + dialogApprove: false, + detailData: [], + selectedPr: {}, + loadingDetail: false, + snackbar: { + state: false, + type: 'success', + message: '', + }, + user_approvelevel: 'x', + status: '', + xstartdate: '', + act_dialog: '', + dialogQty: false, + selectedItems: [], + flag: '', + }, + mutations: { + update_snackbar(state, val) { + state.snackbar = val; + }, + update_loadingDetail(state, val) { + state.loadingDetail = val; + }, + update_selectedPr(state, val) { + state.selectedPr = val; + }, + update_detailData(state, val) { + state.detailData = val; + }, + update_dialogApprove(state, val) { + state.dialogApprove = val; + }, + update_selectedStatus(state, val) { + state.selectedStatus = val; + }, + update_selectedDate(state, val) { + state.selectedDate = val; + }, + update_selectedEndDate(state, val) { + state.selectedEndDate = val; + }, + update_search(state, val) { + state.search = val; + }, + update_loading(state, val) { + state.loading = val; + }, + update_totalPage(state, val) { + state.totalPage = val; + }, + update_selectedPage(state, val) { + state.selectedPage = val; + }, + update_prList(state, val) { + state.prList = val; + }, + update_user_approvelevel(state, val) { + state.user_approvelevel = val + }, + update_status(state, val) { + state.status = val + }, + update_xstartdate(state, val) { + state.xstartdate = val + }, + update_act_dialog(state, val) { + state.act_dialog = val + }, + update_dialogQty(state, val) { + state.dialogQty = val + }, + update_selectedItems(state, val) { + state.selectedItems = val; + }, + update_flag(state, val) { + state.flag = val + }, + }, + actions: { + async search(context) { + context.commit("update_loading", true); + + try { + + var url_string = window.location.href + var url = new URL(url_string); + var status = url.searchParams.get("status"); + var xstartdate = url.searchParams.get("startdate"); + var xsearch = url.searchParams.get("search"); + var xflag = url.searchParams.get("flag"); + + // untuk notifikasi + if (xflag == 'N') { + + if (xsearch != null && xsearch != '') { + context.commit("update_search", xsearch); + } + if (status != null && status != '') { + context.commit("update_selectedStatus", { value: status, title: status }); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedEndDate", xstartdate); + } + + } else if (xflag == 'G') { + // untuk get data param approve all + + if (status != null && status != '') { + context.commit("update_selectedStatus", { value: status, title: status }); + } + if (xstartdate != null && xstartdate != '') { + context.commit("update_selectedDate", xstartdate); + context.commit("update_selectedEndDate", moment(new Date()).format('YYYY-MM-DD')); + } + context.commit("update_flag", xflag); + + } + + var payload = { + token: one_token(), + search: context.state.search, + startDate : context.state.selectedDate, + endDate : context.state.selectedEndDate, + status: context.state.selectedStatus.value, + page: context.state.selectedPage, + flag: context.state.flag, + }; + + let response = await api.search(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + context.commit("update_totalPage", data.total); + context.commit("update_prList", data.records); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + async approve(context, prm) { + context.commit("update_loading", true); + try { + prm.token = one_token() + let response = await api.approve(prm); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + // context.commit("update_totalPage", data.total); + // context.commit("update_prList", data.records); + await context.dispatch("search"); + context.commit("update_dialogApprove", false); + let msg = ''; + if (prm.type === 'A') { + msg = 'Berhasil approve purchase request ' + prm.pr.prNumber + } else if (prm.type === 'R') { + msg = 'Berhasil reject purchase request ' + prm.pr.prNumber + } else if (prm.type === 'U') { + msg = 'Berhasil unapprove purchase request ' + prm.pr.prNumber + } + let snackbar = { + state: true, + type: "success", + message: msg, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + async getDetail(context) { + context.commit("update_loadingDetail", true); + + try { + var payload = { + token: one_token(), + id: context.state.selectedPr.prID, + + }; + + let response = await api.getDetail(payload); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingDetail", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + + context.commit("update_detailData", response.data); + context.commit("update_loadingDetail", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingDetail", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + async getapprovelevel(context) { + context.commit("update_loadingDetail", true); + try { + let payload = { + token: one_token() + } + + let resp = await api.approvelevel(payload) + if (resp.status != 'OK') { + let snackbar = { + state: true, + type: "error", + message: resp.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingDetail", false); + } else { + context.commit("update_user_approvelevel", resp.data.M_UserM_ApproveLevelID) + } + + } catch (error) { + let snackbar = { + state: true, + type: "error", + message: error.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loadingDetail", false); + } + }, + async updateqty(context, prm) { + context.commit("update_loading", true); + try { + prm.token = one_token() + let response = await api.updateqty(prm); + if (response.status != "OK") { + let snackbar = { + state: true, + type: "error", + message: response.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } else { + let data = { + records: response.data.records, + total: response.data.total, + }; + + // context.commit("update_totalPage", data.total); + // context.commit("update_prList", data.records); + await context.dispatch("search"); + context.commit("update_dialogQty", false); + context.commit("update_detailData", []); + let msg = 'Berhasil edit qty'; + let snackbar = { + state: true, + type: "success", + message: msg, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + } + } catch (e) { + let snackbar = { + state: true, + type: "error", + message: e.message, + } + context.commit("update_snackbar", snackbar); + context.commit("update_loading", false); + // context.commit("updateMainTableLoadingStatus", 3); + // context.commit("updateMainTableErrorMessage", e.message); + } + }, + }, +}; diff --git a/test/vuex/accone-purchase-request-kacab/store.js b/test/vuex/accone-purchase-request-kacab/store.js new file mode 100644 index 0000000..2e01b2b --- /dev/null +++ b/test/vuex/accone-purchase-request-kacab/store.js @@ -0,0 +1,14 @@ +import manager from "./modules/manager.js"; +import system from "../../../apps/modules/system/system.js"; +import prkacab from "./modules/prkacab.js" + +export const store = new Vuex.Store({ + modules: { + manager: manager, + system: system, + prkacab: prkacab + }, + state: {}, + mutations: {}, + actions: {}, +}); diff --git a/test/vuex/one-accone-approve-all/api/approve.js b/test/vuex/one-accone-approve-all/api/approve.js new file mode 100644 index 0000000..99b757d --- /dev/null +++ b/test/vuex/one-accone-approve-all/api/approve.js @@ -0,0 +1,39 @@ +const URL = "/one-api/mockup/approvalall/Approvalallrequest/"; + +export async function listApprove(prm) { + try { + var resp = await axios.post(URL + 'listApprove', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/one-accone-approve-all/components/oneApproveList.vue b/test/vuex/one-accone-approve-all/components/oneApproveList.vue new file mode 100644 index 0000000..510ad99 --- /dev/null +++ b/test/vuex/one-accone-approve-all/components/oneApproveList.vue @@ -0,0 +1,190 @@ + + + + + diff --git a/test/vuex/one-accone-approve-all/components/oneApproveListData.vue b/test/vuex/one-accone-approve-all/components/oneApproveListData.vue new file mode 100644 index 0000000..64b882c --- /dev/null +++ b/test/vuex/one-accone-approve-all/components/oneApproveListData.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/test/vuex/one-accone-approve-all/index.php b/test/vuex/one-accone-approve-all/index.php new file mode 100644 index 0000000..729853e --- /dev/null +++ b/test/vuex/one-accone-approve-all/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/one-accone-approve-all/modules/approve.js b/test/vuex/one-accone-approve-all/modules/approve.js new file mode 100644 index 0000000..38bda74 --- /dev/null +++ b/test/vuex/one-accone-approve-all/modules/approve.js @@ -0,0 +1,107 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import { update } from "../../acc-one-md-supplier/api/supplier.js" +import * as api from "../api/approve.js" + +export default { + namespaced: true, + state: { + lookup_search: 0, + lookup_error_message: "", + approvelist: [], + selected_menu: {}, + + listdata: [], + selected_data: {}, + loading: false, + total_page: 0, + current_page: 1, + xsearch: "", + user: one_user() + }, + mutations: { + update_lookup_search(state, val) { + state.lookup_search = val + }, + update_lookup_error_message(state, val) { + state.lookup_error_message = val + }, + update_approvelist(state, val) { + state.approvelist = val + }, + update_selected_menu(state, val) { + state.selected_menu = val + }, + update_listdata(state, val) { + state.listdata = val + }, + update_selected_data(state, val) { + state.selected_data = val + }, + update_loading(state, val) { + state.loading = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_xsearch(state, val) { + state.xsearch = val + }, + update_user(state, val) { + state.user = val + } + }, + actions: { + async listApprove(context, prm) { + context.commit("update_lookup_search", 1) + try { + let prm = {} + prm.token = one_token() + let resp = await api.listApprove(prm) + if (resp.status != "OK") { + context.commit("update_lookup_search", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_search", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records + } + context.commit("update_approvelist", data.records) + } + } catch (e) { + context.commit("update_lookup_search", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + + async search(context) { + context.commit("update_loading", true); + try { + let prm = { + token: one_token() + } + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_lookup_search", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records + } + context.commit("update_listdata", data.records) + + context.commit("update_loading", false); + } + } catch (e) { + context.commit("update_loading", false); + context.commit("update_lookup_error_message", e.message) + } + } + } +} diff --git a/test/vuex/one-accone-approve-all/store.js b/test/vuex/one-accone-approve-all/store.js new file mode 100644 index 0000000..fc91b31 --- /dev/null +++ b/test/vuex/one-accone-approve-all/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import approve from "./modules/approve.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + approve: approve, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); diff --git a/test/vuex/one-accone-list-task/api/approve.js b/test/vuex/one-accone-list-task/api/approve.js new file mode 100644 index 0000000..deecd14 --- /dev/null +++ b/test/vuex/one-accone-list-task/api/approve.js @@ -0,0 +1,20 @@ +const URL = "/one-api/mockup/approvalall/Tasklist/"; + +export async function search(prm) { + try { + var resp = await axios.post(URL + 'search', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/one-accone-list-task/components/oneApproveListData.vue b/test/vuex/one-accone-list-task/components/oneApproveListData.vue new file mode 100644 index 0000000..90797cc --- /dev/null +++ b/test/vuex/one-accone-list-task/components/oneApproveListData.vue @@ -0,0 +1,185 @@ + + + + + diff --git a/test/vuex/one-accone-list-task/index.php b/test/vuex/one-accone-list-task/index.php new file mode 100644 index 0000000..729853e --- /dev/null +++ b/test/vuex/one-accone-list-task/index.php @@ -0,0 +1,73 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vuex/one-accone-list-task/modules/approve.js b/test/vuex/one-accone-list-task/modules/approve.js new file mode 100644 index 0000000..71b50c5 --- /dev/null +++ b/test/vuex/one-accone-list-task/modules/approve.js @@ -0,0 +1,71 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/approve.js" + +export default { + namespaced: true, + state: { + lookup_search: 0, + lookup_error_message: "", + + listdata: [], + selected_data: {}, + loading: false, + total_page: 0, + current_page: 1, + xsearch: "" + }, + mutations: { + update_lookup_search(state, val) { + state.lookup_search = val + }, + update_lookup_error_message(state, val) { + state.lookup_error_message = val + }, + update_listdata(state, val) { + state.listdata = val + }, + update_selected_data(state, val) { + state.selected_data = val + }, + update_loading(state, val) { + state.loading = val + }, + update_total_page(state, val) { + state.total_page = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_xsearch(state, val) { + state.xsearch = val + }, + }, + actions: { + async search(context) { + context.commit("update_loading", true); + try { + let prm = { + token: one_token() + } + let resp = await api.search(prm) + if (resp.status != "OK") { + context.commit("update_lookup_search", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records + } + context.commit("update_listdata", data.records) + + context.commit("update_loading", false); + } + } catch (e) { + context.commit("update_loading", false); + context.commit("update_lookup_error_message", e.message) + } + } + } +} diff --git a/test/vuex/one-accone-list-task/store.js b/test/vuex/one-accone-list-task/store.js new file mode 100644 index 0000000..fc91b31 --- /dev/null +++ b/test/vuex/one-accone-list-task/store.js @@ -0,0 +1,23 @@ +// State +// data ... +// Mutations +// +// +// Actions +import approve from "./modules/approve.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + approve: approve, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); diff --git a/test/vuex/one-md-priviledge/.index.php.swp b/test/vuex/one-md-priviledge/.index.php.swp new file mode 100755 index 0000000..36a9106 Binary files /dev/null and b/test/vuex/one-md-priviledge/.index.php.swp differ diff --git a/test/vuex/one-md-priviledge/action.js b/test/vuex/one-md-priviledge/action.js new file mode 100755 index 0000000..e69de29 diff --git a/test/vuex/one-md-priviledge/api.js b/test/vuex/one-md-priviledge/api.js new file mode 100755 index 0000000..47e14ba --- /dev/null +++ b/test/vuex/one-md-priviledge/api.js @@ -0,0 +1,31 @@ +// API : +// search bank +// paramater : query , page , rowPerPage +const URL = + "http://lebaran.aplikasi.web.id/smartlab_api/vuex/t02/search_bank"; + +export async function searchBank(query, page, rowPerPage = 15) { + try { + var resp = await axios.post(URL, { + query: query, + page: page, + rowPerPage: rowPerPage + }); + if (resp.status != 200) { + return { + status: "ERR", + query: query, + message: resp.statusText + }; + } + let data = resp.data; + data.query = query; + return data; + } catch (e) { + return { + status: "ERR", + query: query, + message: e.message + }; + } +} diff --git a/test/vuex/one-md-priviledge/api/priviledge.js b/test/vuex/one-md-priviledge/api/priviledge.js new file mode 100755 index 0000000..e959c42 --- /dev/null +++ b/test/vuex/one-md-priviledge/api/priviledge.js @@ -0,0 +1,39 @@ +const URL = "/one-api/mockup/masterdata/"; + +export async function lookup(prm) { + try { + var resp = await axios.post(URL + 'priviledge/lookuppriviledge', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(token,prm) { + try { + var resp = await axios.post(URL + 'priviledge/save', {token:token,datas:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/one-md-priviledge/api/usergroup.js b/test/vuex/one-md-priviledge/api/usergroup.js new file mode 100755 index 0000000..bb87283 --- /dev/null +++ b/test/vuex/one-md-priviledge/api/usergroup.js @@ -0,0 +1,20 @@ +const URL = "/one-api/mockup/masterdata/"; + +export async function lookup(token, search,all ) { + try { + var resp = await axios.post(URL + 'priviledge/lookupusergroup', { token: token, search: search, all:all }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} diff --git a/test/vuex/one-md-priviledge/components/headerBox.vue b/test/vuex/one-md-priviledge/components/headerBox.vue new file mode 100755 index 0000000..cd8df75 --- /dev/null +++ b/test/vuex/one-md-priviledge/components/headerBox.vue @@ -0,0 +1,43 @@ + + + + diff --git a/test/vuex/one-md-priviledge/components/oneMdPriviledge.vue b/test/vuex/one-md-priviledge/components/oneMdPriviledge.vue new file mode 100755 index 0000000..3cea198 --- /dev/null +++ b/test/vuex/one-md-priviledge/components/oneMdPriviledge.vue @@ -0,0 +1,264 @@ + + + + + diff --git a/test/vuex/one-md-priviledge/components/oneMdUsergroupList.vue b/test/vuex/one-md-priviledge/components/oneMdUsergroupList.vue new file mode 100755 index 0000000..fada09c --- /dev/null +++ b/test/vuex/one-md-priviledge/components/oneMdUsergroupList.vue @@ -0,0 +1,311 @@ + + + + + diff --git a/test/vuex/one-md-priviledge/index.php b/test/vuex/one-md-priviledge/index.php new file mode 100755 index 0000000..6956e6e --- /dev/null +++ b/test/vuex/one-md-priviledge/index.php @@ -0,0 +1,78 @@ + + + + + + + + One + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/one-md-priviledge/modules/priviledge.js b/test/vuex/one-md-priviledge/modules/priviledge.js new file mode 100755 index 0000000..83d329f --- /dev/null +++ b/test/vuex/one-md-priviledge/modules/priviledge.js @@ -0,0 +1,99 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/priviledge.js" + +export default { + namespaced: true, + state: { + act:'new', + lookup_priviledge: 0, + lookup_error_message: '', + priviledges: [], + save_status: 0, + save_error_message: '', + dialog_success: false, + msg_success: "", + listregional: [{"id":"1", "name":"Regional", "code":"R"},{"id":"2", "name":"Cabang","code":"N"}], + selected_listregional:{"id":"1", "name":"Regional","code":"R"} + }, + mutations: { + update_listregional(state, val) { + state.listregional = val + }, + update_selected_listregional(state, val) { + state.selected_listregional = val + }, + update_act(state, val) { + state.act = val + }, + update_lookup_error_message(state, status) { + state.lookup_error_message = status + }, + update_lookup_priviledge(state, status) { + state.lookup_priviledge = status + }, + update_priviledges(state, data) { + state.priviledges = data + }, + update_selected_priviledge(state, val) { + state.selected_priviledge = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_dialog_success(state, val) { + state.dialog_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + } + }, + actions: { + async lookup(context, prm) { + context.commit("update_lookup_priviledge", 1) + try { + prm.token = one_token() + let resp = await api.lookup(prm) + if (resp.status != "OK") { + context.commit("update_lookup_priviledge", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_priviledge", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records + } + context.commit("update_priviledges", data.records) + } + } catch (e) { + context.commit("update_lookup_priviledge", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async save(context, prm) { + context.commit("update_save_status", 1) + try { + let resp = await api.save(one_token(),prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", "") + + context.commit("update_dialog_success", true) + var msg = "Data sudah terupdate dong ..." + context.commit("update_msg_success", msg) + context.commit("usergroup/update_no_save", false, { root: true }) + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/one-md-priviledge/modules/usergroup.js b/test/vuex/one-md-priviledge/modules/usergroup.js new file mode 100755 index 0000000..caf6c8c --- /dev/null +++ b/test/vuex/one-md-priviledge/modules/usergroup.js @@ -0,0 +1,98 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/usergroup.js" + +export default { + namespaced: true, + state: { + act:'new', + lookup_usergroup: 0, + lookup_error_message: '', + usergroups: [], + total_usergroups: 0, + total_filter_usergroups: 0, + selected_usergroup: { name: "[ Belum memilih Grup User ]" }, + save_status: 0, + save_error_message: '', + dialog_form_usergroup: false, + dialog_edit_form_usergroup:false, + alert_success: false, + msg_success: "", + show_all:'N', + no_save:false, + open_alert_confirmation:false + }, + mutations: { + update_act(state, val) { + state.act = val + }, + update_show_all(state, val) { + state.show_all = val + }, + update_lookup_error_message(state, status) { + state.lookup_error_message = status + }, + update_lookup_usergroup(state, status) { + state.lookup_usergroup = status + }, + update_usergroups(state, data) { + state.usergroups = data.records + state.total_usergroups = data.total + state.total_filter_usergroups = data.total_filter + }, + update_selected_usergroup(state, val) { + state.selected_usergroup = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_dialog_form_usergroup(state, val) { + state.dialog_form_usergroup = val + }, + update_dialog_edit_form_usergroup(state, val) { + state.dialog_edit_form_usergroup = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_no_save(state, val) { + state.no_save = val + }, + update_open_alert_confirmation(state, val) { + state.open_alert_confirmation = val + } + }, + actions: { + async lookup(context, prm) { + context.commit("update_lookup_usergroup", 1) + try { + let resp = await api.lookup(one_token(), prm.search, prm.all) + if (resp.status != "OK") { + context.commit("update_lookup_usergroup", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_usergroup", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total, + total_filter: resp.data.total_filter + } + context.commit("update_usergroups", data) + context.commit("update_selected_usergroup", data.records[0]) + context.dispatch("priviledge/lookup",{id:data.records[0].id,code:context.rootState.priviledge.selected_listregional.code}, { root: true }) + } + } catch (e) { + context.commit("update_lookup_usergroup", 3) + context.commit("update_lookup_error_message", e.message) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/one-md-priviledge/mutation.js b/test/vuex/one-md-priviledge/mutation.js new file mode 100755 index 0000000..e69de29 diff --git a/test/vuex/one-md-priviledge/store.js b/test/vuex/one-md-priviledge/store.js new file mode 100755 index 0000000..0a0d413 --- /dev/null +++ b/test/vuex/one-md-priviledge/store.js @@ -0,0 +1,25 @@ +// State +// data ... +// Mutations +// +// +// Actions +import usergroup from "./modules/usergroup.js"; +import priviledge from "./modules/priviledge.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + usergroup: usergroup, + priviledge:priviledge, + system: system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/one-md-staff-v2/api/staff.js b/test/vuex/one-md-staff-v2/api/staff.js new file mode 100644 index 0000000..f84f2fa --- /dev/null +++ b/test/vuex/one-md-staff-v2/api/staff.js @@ -0,0 +1,269 @@ +const URL = "/one-api/mockup/masterdata/"; + +export async function search(token, name, snik, status) { + try { + var resp = await axios.post(URL + 'staffv2/search', { + token:token, + nama: name, + snik: snik, + status: status + }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function getsexreg(token) { + try { + var resp = await axios.post(URL + 'staffv2/getsexreg',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function save(prm) { + try { + var resp = await axios.post(URL + 'staffv2/save',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function newstaff(prm) { + try { + var resp = await axios.post(URL + 'staffv2/newstaff',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(prm) { + try { + var resp = await axios.post(URL + 'staffv2/deletestaff',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function saveposition(prm) { + try { + var resp = await axios.post(URL + 'staffv2/addnewposition', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function updateposition(prm) { + try { + var resp = await axios.post(URL + 'staffv2/editposition', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function deleteposition(prm) { + try { + var resp = await axios.post(URL + 'staffv2/deleteposition', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getaddress(prm) { + try { + var resp = await axios.post(URL + 'staffv2/getaddress',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function searchcity(token,prm) { + try { + var resp = await axios.post(URL + 'staffv2/searchcity',{token:token,search:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function getsubarea(token,prm) { + try { + var resp = await axios.post(URL + 'staffv2/getsubarea',{id:prm.M_CityID,token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + +export async function savenewaddress(prm) { + try { + var resp = await axios.post(URL + 'staffv2/savenewaddress',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function saveeditaddress(prm) { + try { + var resp = await axios.post(URL + 'staffv2/saveeditaddress',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function deleteaddress(prm) { + try { + var resp = await axios.post(URL + 'staffv2/deleteaddress',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} \ No newline at end of file diff --git a/test/vuex/one-md-staff-v2/components/oneMdStaffDetail.vue b/test/vuex/one-md-staff-v2/components/oneMdStaffDetail.vue new file mode 100644 index 0000000..ac5d328 --- /dev/null +++ b/test/vuex/one-md-staff-v2/components/oneMdStaffDetail.vue @@ -0,0 +1,684 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/one-md-staff-v2/components/oneMdStaffList.vue b/test/vuex/one-md-staff-v2/components/oneMdStaffList.vue new file mode 100644 index 0000000..e838e76 --- /dev/null +++ b/test/vuex/one-md-staff-v2/components/oneMdStaffList.vue @@ -0,0 +1,297 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/one-md-staff-v2/index.php b/test/vuex/one-md-staff-v2/index.php new file mode 100644 index 0000000..11f7170 --- /dev/null +++ b/test/vuex/one-md-staff-v2/index.php @@ -0,0 +1,94 @@ + + + + + + + + One + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/one-md-staff-v2/modules/staff.js b/test/vuex/one-md-staff-v2/modules/staff.js new file mode 100644 index 0000000..580f77f --- /dev/null +++ b/test/vuex/one-md-staff-v2/modules/staff.js @@ -0,0 +1,624 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/staff.js" + +export default { + namespaced: true, + state: { + last_id:-1, + last_saved_id:-1, + x_addr_id:0, + act:'edit', + act_addr:'new', + get_data_status:0, + search_staff: 0, + search_status: 0, + statuses:[{label:'Bukan Kurir', value:'N'},{label:'Sebagai Kurir', value:'Y'}], + selected_status:{label:'Bukan Kurir', value:'N'}, + search_error_message: '', + dobs:[], + selected_dob:{}, + dob: '', + staff_name:'', + staffs: [], + total_staffs:0, + sexes:[], + selected_sex:{}, + address:'', + cities: [], + city_address: {}, + subareas: [], + subarea_address: {}, + phone:'', + hp:'', + branchs:[], + selected_branch:{}, + religions:[], + selected_religion:{}, + startdate:'', + enddate:'', + positions:[], + selected_position:{}, + nik:'', + timework:'', + timeworksaturday:'', + blood:'', + study:'', + iscourier:'N', + total_staff: 0, + selected_staff: {}, + save_status: 0, + btn_save_seen: true, + pgrs_save: false, + save_error_message: '', + no_save: 0, + open_alert_confirmation:false, + alert_success: false, + msg_success: "", + dialog_success: false, + dialog_confirmation_delete: false, + msg_confirmation_delete: "", + dialog_confirmation_delete_addr: false, + msg_confirmation_delete_addr: "", + autocomplete_status:0, + dialog_form_address: false, + errors:[], + dialog_form_position: false, + ihsnumber: '' + }, + mutations: { + update_x_addr_id(state, val) { + state.x_addr_id = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_last_saved_id(state, val) { + state.last_saved_id = val + }, + update_act(state, val) { + state.act = val + }, + update_act_addr(state, val) { + state.act_addr = val + }, + update_get_data_status(state, val) { + state.get_data_status = val + }, + update_search_error_message(state, patient) { + state.search_error_message = patient + }, + update_search_staff(state, staff) { + state.search_staff = staff + }, + update_staff_name(state, val) { + state.staff_name = val + }, + update_staffs(state, data) { + state.staffs = data + }, + update_selected_staff(state, val) { + state.selected_staff = val + }, + update_dob(state, val) { + state.dob = val + }, + update_sexes(state, val) { + state.sexes = val + }, + update_selected_sex(state, val) { + state.selected_sex = val + }, + update_address(state, val) { + state.address = val + }, + update_cities(state, val) { + state.cities = val + }, + update_city_address(state, val) { + state.city_address = val + }, + update_subareas(state, val) { + state.subareas = val + }, + update_subarea_address(state, val) { + state.subarea_address = val + }, + update_phone(state, val) { + state.phone = val + }, + update_hp(state, val) { + state.hp = val + }, + update_religions(state, val) { + state.religions = val + }, + update_selected_religion(state, val) { + state.selected_religion = val + }, + update_branchs(state, val) { + state.branchs = val + }, + update_selected_branch(state, val) { + state.selected_branch = val + }, + update_startdate(state, val) { + state.startdate = val + }, + update_enddate(state, val) { + state.enddate = val + }, + update_positions(state, val) { + state.positions = val + }, + update_selected_position(state, val) { + state.selected_position = val + }, + update_nik(state, val) { + state.nik = val + }, + update_timework(state, val) { + state.timework = val + }, + update_timeworksaturday(state, val) { + state.timeworksaturday = val + }, + update_blood(state, val) { + state.blood = val + }, + update_study(state, val) { + state.study = val + }, + update_iscourier(state, val) { + state.iscourier = val + }, + update_btn_save_seen(state, val) { + state.btn_save_seen = val + }, + update_pgrs_save(state, val) { + state.pgrs_save = val + }, + update_save_error_message(state, msg) { + state.save_error_message = '' + }, + update_no_save(state, val) { + state.no_save = val + }, + update_open_alert_confirmation(state, val) { + state.open_alert_confirmation = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_dialog_success(state, val) { + state.dialog_success = val + }, + update_dialog_confirmation_delete(state, val) { + state.dialog_confirmation_delete = val + }, + update_msg_confirmation_delete(state, val) { + state.msg_confirmation_delete = val + }, + update_dialog_confirmation_delete_addr(state, val) { + state.dialog_confirmation_delete_addr = val + }, + update_msg_confirmation_delete_addr(state, val) { + state.msg_confirmation_delete_addr = val + }, + update_addresses(state, val) { + state.addresses = val + }, + update_autocomplete_status(state,val){ + state.autocomplete_status = val + }, + update_dialog_form_address(state, val) { + state.dialog_form_address = val + }, + update_label_address(state, val) { + state.label_address = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_errors(state, val) { + state.errors = val + }, + update_total_staffs(state, val) { + state.total_staffs = val + }, + update_selected_status(state, val) { + state.selected_status = val + }, + update_dialog_form_position(state, val) { + state.dialog_form_position = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_ihsnumber(state, val) { + state.ihsnumber = val + } + }, + actions: { + async search(context, prm) { + context.commit("update_search_staff", 1) + try { + let resp = await api.search(one_token(), prm.name, prm.snik, prm.status) + if (resp.status != "OK") { + context.commit("update_search_staff", 3) + context.commit("update_search_error_message", resp.message) + } else { + context.commit("update_search_staff", 2) + context.commit("update_search_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_staffs", data.records) + context.commit("update_total_staffs", data.total) + context.commit("update_no_save", 0) + if(prm.lastid === -1){ + context.commit("update_selected_staff", data.records[0]) + var sta = data.records[0] + context.commit("update_selected_branch",{M_BranchID:sta.M_StaffM_BranchID,M_BranchName:sta.M_BranchName}) + context.commit("update_staff_name",sta.M_StaffName) + context.commit("update_dob",sta.M_StaffDOBx) + context.commit("update_selected_sex",{M_SexID:sta.M_StaffM_SexID,m_sexname:sta.m_sexname}) + context.commit("update_address",sta.M_StaffAddress) + context.commit("update_cities",[{M_CityID:sta.M_StaffM_CityID,M_CityName:sta.M_CityName}]) + context.commit("update_city_address",{M_CityID:sta.M_StaffM_CityID,M_CityName:sta.M_CityName}) + context.commit("update_subareas",[{M_SubareaID:sta.M_StaffM_SubareaID,M_SubareaName:sta.M_SubareaName}]) + context.commit("update_subarea_address",{M_SubareaID:sta.M_StaffM_SubareaID,M_SubareaName:sta.M_SubareaName}) + context.commit("update_phone",sta.M_StaffPhone) + context.commit("update_hp",sta.M_StaffHP) + context.commit("update_selected_religion",{M_ReligionID:sta.M_StaffM_ReligionID,M_ReligionName:sta.M_ReligionName}) + context.commit("update_startdate",sta.M_StaffStartDate) + context.commit("update_enddate",sta.M_StaffEndDate) + context.commit("update_selected_position",{M_PositionID:sta.M_StaffM_PositionID,M_PositionName:sta.M_PositionName}) + context.commit("update_nik",sta.M_StaffNIK) + context.commit("update_timework",sta.M_StaffTimeWork) + context.commit("update_timeworksaturday",sta.M_StaffTimeWorkSaturday) + context.commit("update_blood",sta.M_StaffBlood) + context.commit("update_study",sta.M_StaffStudy) + context.commit("update_iscourier",sta.M_StaffIsCourier) + context.commit("update_ihsnumber",sta.OHStaffMapIhsNumber) + } + else{ + context.commit("update_selected_staff", data.records[prm.lastid]) + var sta = data.records[prm.lastid] + context.commit("update_selected_branch",{M_BranchID:sta.M_StaffM_BranchID,M_BranchName:sta.M_BranchName}) + context.commit("update_staff_name",sta.M_StaffName) + context.commit("update_dob",sta.M_StaffDOBx) + context.commit("update_selected_sex",{M_SexID:sta.M_StaffM_SexID,m_sexname:sta.m_sexname}) + context.commit("update_address",sta.M_StaffAddress) + context.commit("update_cities",[{M_CityID:sta.M_StaffM_CityID,M_CityName:sta.M_CityName}]) + context.commit("update_city_address",{M_CityID:sta.M_StaffM_CityID,M_CityName:sta.M_CityName}) + context.commit("update_subareas",[{M_SubareaID:sta.M_StaffM_SubareaID,M_SubareaName:sta.M_SubareaName}]) + context.commit("update_subarea_address",{M_SubareaID:sta.M_StaffM_SubareaID,M_SubareaName:sta.M_SubareaName}) + context.commit("update_phone",sta.M_StaffPhone) + context.commit("update_hp",sta.M_StaffHP) + context.commit("update_selected_religion",{M_ReligionID:sta.M_StaffM_ReligionID,M_ReligionName:sta.M_ReligionName}) + context.commit("update_startdate",sta.M_StaffStartDate) + context.commit("update_enddate",sta.M_StaffEndDate) + context.commit("update_selected_position",{M_PositionID:sta.M_StaffM_PositionID,M_PositionName:sta.M_PositionName}) + context.commit("update_nik",sta.M_StaffNIK) + context.commit("update_timework",sta.M_StaffTimeWork) + context.commit("update_timeworksaturday",sta.M_StaffTimeWorkSaturday) + context.commit("update_blood",sta.M_StaffBlood) + context.commit("update_study",sta.M_StaffStudy) + context.commit("update_iscourier",sta.M_StaffIsCourier) + context.commit("update_ihsnumber",sta.OHStaffMapIhsNumber) + } + + } + } catch (e) { + context.commit("update_search_staff", 3) + context.commit("update_search_error_message", e.message) + console.log(e) + } + }, + async getsexreg(context) { + context.commit("update_get_data_status",1) + try { + let resp= await api.getsexreg(one_token()) + if (resp.status != "OK") { + context.commit("update_get_data_status",3) + } else { + context.commit("update_get_data_status",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_sexes",data.records.sexes) + context.commit("update_religions",data.records.religions) + context.commit("update_branchs",data.records.branchs) + context.commit("update_positions",data.records.positions) + } + } catch(e) { + context.commit("update_get_data_status",3) + } + }, + async save(context,prm) { + context.commit("update_save_status",1) + try { + prm.token = one_token() + let resp= await api.save(prm) + if (resp.status != "OK") { + context.commit("update_save_status",3) + } else { + context.commit("update_save_status",2) + context.commit("update_last_id", prm.M_StaffID) + context.commit("update_dialog_success", true) + var msg = "Data karyawan " + prm.M_StaffName + " sudah terupdate dong ..." + context.commit("update_msg_success", msg) + + } + } catch(e) { + context.commit("update_save_status",3) + } + }, + async newstaff(context,prm) { + context.commit("update_save_status",1) + try { + prm.token = one_token() + let resp= await api.newstaff(prm) + if (resp.status != "OK") { + context.commit("update_save_status",3) + } else { + context.commit("update_save_status",2) + // console.log(resp.data.id) + context.commit("update_last_id", resp.data.id) + context.commit("update_dialog_success", true) + var msg = "Data karyawan " + prm.M_StaffName + " sudah tersimpan dong ..." + context.commit("update_msg_success", msg) + + } + } catch(e) { + context.commit("update_save_status",3) + } + }, + async delete(context,prm) { + context.commit("update_save_status",1) + try { + prm.token = one_token() + let resp= await api.xdelete(prm) + if (resp.status != "OK") { + context.commit("update_save_status",3) + } else { + context.commit("update_save_status",2) + context.commit("update_last_id", 0) + context.commit("update_dialog_confirmation_delete",false) + context.commit("update_dialog_success", true) + var msg = "Data karyawan " + prm.M_StaffName + " sudah dihapus dong ..." + context.commit("update_msg_success", msg) + context.commit("update_selected_branch", {}) + context.commit("update_staff_name", '') + context.commit("update_dob", '') + context.commit("update_selected_sex", {}) + context.commit("update_address", '') + context.commit("update_city_address", {}) + context.commit("update_subarea_address", {}) + context.commit("update_phone", '') + context.commit("update_hp", '') + context.commit("update_selected_religion", {}) + context.commit("update_startdate", '') + context.commit("update_enddate", '') + context.commit("update_selected_position", {}) + context.commit("update_nik", '') + context.commit("update_timework", '') + context.commit("update_timeworksaturday", '') + context.commit("update_blood", '') + context.commit("update_study", '') + context.commit("update_iscourier",'N') + } + } catch(e) { + context.commit("update_save_status",3) + } + }, + async saveposition(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.saveposition(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_save_error_message", resp.message) + var data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_positions", resp.data.records.positions) + } else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async updateposition(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.updateposition(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_save_error_message", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_positions", resp.data.records.positions) + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async deleteposition(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.deleteposition(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_save_error_message", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + if (data.total !== -1) { + context.commit("update_positions", resp.data.records.positions) + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async getaddress(context,prm) { + context.commit("update_save_status",1) + try { + prm.token = one_token() + let resp= await api.getaddress(prm) + if (resp.status != "OK") { + context.commit("update_save_status",3) + } else { + context.commit("update_save_status",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_addresses",data.records) + } + } catch(e) { + context.commit("update_save_status",3) + } + }, + async searchcity(context,prm) { + context.commit("update_autocomplete_status",1) + try { + let resp= await api.searchcity(one_token(),prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status",3) + } else { + context.commit("update_autocomplete_status",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_cities",resp.data.records) + } + } catch(e) { + context.commit("update_autocomplete_status",3) + } + }, + async getsubarea(context,prm) { + context.commit("update_get_data_status",1) + try { + let resp= await api.getsubarea(one_token(),prm) + if (resp.status != "OK") { + context.commit("update_get_data_status",3) + } else { + context.commit("update_get_data_status",2) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_subareas",resp.data.records) + } + } catch(e) { + context.commit("update_get_data_status",3) + } + }, + async savenewaddress(context,prm) { + context.commit("update_save_status",1) + try { + prm.token = one_token() + let resp= await api.savenewaddress(prm) + if (resp.status != "OK") { + context.commit("update_save_status",3) + } else { + context.commit("update_save_status",2) + context.commit("update_dialog_form_address",false) + context.commit("update_last_id", prm.M_StaffAddressM_StaffID) + context.commit("update_dialog_success", true) + var msg = "Penambahan data alamat karyawan " + prm.M_StaffName + " sudah berhasil dong ..." + context.commit("update_msg_success", msg) + + } + } catch(e) { + context.commit("update_save_status",3) + } + }, + async saveeditaddress(context,prm) { + context.commit("update_save_status",1) + try { + prm.token = one_token() + let resp= await api.saveeditaddress(prm) + if (resp.status != "OK") { + context.commit("update_save_status",3) + } else { + context.commit("update_save_status",2) + context.commit("update_dialog_form_address",false) + context.commit("update_last_id", prm.M_StaffAddressM_StaffID) + context.commit("update_dialog_success", true) + var msg = "Perubahan data alamat karyawan " + prm.M_StaffName + " sudah berhasil dong ..." + context.commit("update_msg_success", msg) + + } + } catch(e) { + context.commit("update_save_status",3) + } + }, + async deleteaddress(context,prm) { + context.commit("update_save_status",1) + try { + prm.token = one_token() + let resp= await api.deleteaddress(prm) + if (resp.status != "OK") { + context.commit("update_save_status",3) + } else { + context.commit("update_save_status",2) + context.commit("update_dialog_confirmation_delete_addr",false) + context.commit("update_last_id", prm.M_StaffAddressM_StaffID) + context.commit("update_dialog_success", true) + var msg = "Penghapusan data alamat "+prm.M_StaffAddressNote+" dari karyawan " + prm.M_StaffName + " sudah berhasil dong ..." + context.commit("update_msg_success", msg) + + } + } catch(e) { + context.commit("update_save_status",3) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/one-md-staff-v2/store.js b/test/vuex/one-md-staff-v2/store.js new file mode 100644 index 0000000..f593f80 --- /dev/null +++ b/test/vuex/one-md-staff-v2/store.js @@ -0,0 +1,27 @@ +// State +// data ... +// Mutations +// +// +// Actions +import staff from "./modules/staff.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + staff: staff, + system: system + }, + state: { + tab_selected: 'staff' + }, + mutations: { + change_tab(state, ntab) { + state.tab_selected = ntab + } + }, + actions: { + change_tab(context, ntab) { + context.commit('change_tab', ntab) + } + } +}); \ No newline at end of file diff --git a/test/vuex/one-report-usergroup/api/report.js b/test/vuex/one-report-usergroup/api/report.js new file mode 100644 index 0000000..c3c52c9 --- /dev/null +++ b/test/vuex/one-report-usergroup/api/report.js @@ -0,0 +1,202 @@ +const URL = "/one-api/v1/report-usergroup/"; + +export async function save(prm) { + try { + var resp = await axios.post(URL + 'usergroup/addnewreport', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function saveaddeditreport(prm) { + try { + var resp = await axios.post(URL + 'usergroup/saveaddeditreport', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function saveallreportdetail(prm) { + try { + var resp = await axios.post(URL + 'usergroup/saveallreport', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function lookup(prm) { + try { + var resp = await axios.post(URL + 'usergroup/lookupreportbyid', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function xdelete(token,id) { + try { + var resp = await axios.post(URL + 'usergroup/deletereport', { id: id ,token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getstatus(token) { + try { + var resp = await axios.post(URL + 'usergroup/getstatus',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function searchuser(prm) { + try { + var resp = await axios.post(URL + 'usergroup/searchuser',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + export async function searchtest(prm) { + try { + var resp = await axios.post(URL + 'usergroup/searchtest',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + export async function searchdoctor(prm) { + try { + var resp = await axios.post(URL + 'usergroup/searchdoctor',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } +export async function lookupbyname(prm) { + try { + var resp = await axios.post(URL + 'usergroup/lookupreportbyname', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function selectaddressdoctor(prm) { + try { + var resp = await axios.post(URL + 'usergroup/selectaddressdoctor',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } \ No newline at end of file diff --git a/test/vuex/one-report-usergroup/api/user.js b/test/vuex/one-report-usergroup/api/user.js new file mode 100644 index 0000000..6abe4ee --- /dev/null +++ b/test/vuex/one-report-usergroup/api/user.js @@ -0,0 +1,243 @@ +const URL = "/one-api/v1/report-usergroup/"; + +export async function lookup(prm) { + try { + var resp = await axios.post(URL + 'usergroup/lookup', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function lookupbyname(prm) { + try { + var resp = await axios.post(URL + 'usergroup/lookupuserbyname', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function getsexreg(token) { + try { + var resp = await axios.post(URL + 'usergroup/getsexreg',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function save(prm) { + try { + var resp = await axios.post(URL + 'usergroup/addnewuser', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function update(prm) { + try { + var resp = await axios.post(URL + 'usergroup/edituser', prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + + +export async function xdelete(token,id) { + try { + var resp = await axios.post(URL + 'usergroup/deleteuser', { id: id, token:token }); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch (e) { + return { + status: "ERR", + message: e.message + }; + } +} + +export async function selectnonlab(token) { + try { + var resp = await axios.post(URL + 'usergroup/selectnonlab',{token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function searchdetail(token,prm) { + try { + var resp = await axios.post(URL + 'usergroup/searchdetail',{token:token,search:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function searchdoctor(token,prm) { + try { + var resp = await axios.post(URL + 'usergroup/searchdoctor',{token:token,search:prm}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + export async function searchinstrument(token,tes) { + try { + var resp = await axios.post(URL + 'usergroup/searchinstrument',{token:token,search:tes}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + export async function searchtemplate(token,tes) { + try { + var resp = await axios.post(URL + 'usergroup/searchtemplate',{token:token,search:tes}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + export async function getdistrict(token,prm) { + try { + var resp = await axios.post(URL + 'usergroup/getdistrict',{id:prm.Nat_NormalValueDetailID,token:token}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + + export async function getkelurahan(token,prm) { + try { + var resp = await axios.post(URL + 'usergroup/getkelurahan',{token:token,id:prm.M_DistrictID}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } \ No newline at end of file diff --git a/test/vuex/one-report-usergroup/components/oneMdReportList.vue b/test/vuex/one-report-usergroup/components/oneMdReportList.vue new file mode 100644 index 0000000..dc3e670 --- /dev/null +++ b/test/vuex/one-report-usergroup/components/oneMdReportList.vue @@ -0,0 +1,811 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/one-report-usergroup/components/oneMdUserList.vue b/test/vuex/one-report-usergroup/components/oneMdUserList.vue new file mode 100644 index 0000000..00b3826 --- /dev/null +++ b/test/vuex/one-report-usergroup/components/oneMdUserList.vue @@ -0,0 +1,647 @@ + + + + + \ No newline at end of file diff --git a/test/vuex/one-report-usergroup/index.php b/test/vuex/one-report-usergroup/index.php new file mode 100644 index 0000000..366d554 --- /dev/null +++ b/test/vuex/one-report-usergroup/index.php @@ -0,0 +1,77 @@ + + + + + + + + One + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/one-report-usergroup/modules/report.js b/test/vuex/one-report-usergroup/modules/report.js new file mode 100644 index 0000000..f1f1178 --- /dev/null +++ b/test/vuex/one-report-usergroup/modules/report.js @@ -0,0 +1,637 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/report.js" + +export default { + namespaced: true, + state: { + reports: [], + save_status: 0, + save_error_message: '', + dialog_form_report: false, + dialog_status_order: false, + lookup_report: 0, + search_status: 0, + errors: [], + startdate: moment(new Date()).format('YYYY-MM-DD'), + enddate: moment(new Date()).format('YYYY-MM-DD'), + bases: [], + base: {}, + omzettypes: [], + omzettype: {}, + reporttypes: [], + reporttype: {}, + agingtypes: [], + agingtype: {}, + statuss: [], + autousers:[], + autouser:{}, + autocitys:[], + autocity:{}, + autodistricts:[], + autodistrict:{}, + autokelurahans:[], + autokelurahan:{}, + autotests:[], + autotest:{}, + automous:[], + automou:{}, + autodoctors:[], + autodoctor:{}, + addressdoctors:[], + addressdoctor:{}, + current_page:1, + x_search: '', + total_data: 0, + selected_report: { + name: "" + }, + get_data_status: 0, + get_data_error_message: '', + new_report:'', + value_new_report:'', + new_reportname:'', + value_new_reportname:'', + selected_filter_status: {}, + f_statuss: [], + reportcode:'', + reportgroup: '', + reportname:'' + }, + mutations: { + update_reportgroup(state, val) { + state.reportgroup = val + }, + update_reportcode(state, val) { + state.reportcode = val + }, + update_reportname(state, val) { + state.reportname = val + }, + update_selected_filter_status(state, val) { + state.selected_filter_status = val + }, + update_f_statuss(state, val) { + state.f_statuss = val + }, + update_value_new_report(state, val){ + state.value_new_report = val + }, + update_new_report(state, val) { + state.new_report = val + }, + update_value_new_reportname(state, val){ + state.value_new_reportname = val + }, + update_new_reportname(state, val) { + state.new_reportname = val + }, + update_selected_report(state, val) { + state.selected_report = val + }, + update_x_search(state, val) { + state.x_search = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_total_data(state, val) { + state.total_data = val + }, + update_autousers(state,data){ + state.autousers = data + }, + update_autouser(state,val){ + state.autouser = val + }, + update_autocitys(state,data){ + state.autocitys = data + }, + update_autocity(state,val){ + state.autocity = val + }, + update_autotests(state,data){ + state.autotests = data + }, + update_autotest(state,val){ + state.autotest = val + }, + update_automous(state,data){ + state.automous = data + }, + update_automou(state,val){ + state.automou = val + }, + update_autodoctors(state,data){ + state.autodoctors = data + }, + update_autodoctor(state,val){ + state.autodoctor = val + }, + update_addressdoctors(state,data){ + state.addressdoctors = data + }, + update_addressdoctor(state,val){ + state.addressdoctor = val + }, + update_autodistricts(state,data){ + state.autodistricts = data + }, + update_autodistrict(state,val){ + state.autodistrict = val + }, + update_autokelurahans(state,data){ + state.autokelurahans = data + }, + update_autokelurahan(state,val){ + state.autokelurahan = val + }, + update_errors(state, val) { + state.errors = val + }, + update_reports(state, data) { + state.reports = data + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_dialog_form_report(state, val) { + state.dialog_form_report = val + }, + update_lookup_report(state, val) { + state.lookup_report = val + }, + update_startdate(state, val) { + state.startdate = val + }, + update_enddate(state, val) { + state.enddate = val + }, + update_bases(state, data) { + state.bases = data + }, + update_base(state, val) { + state.base = val + }, + update_omzettypes(state, data) { + state.omzettypes = data + }, + update_omzettype(state, val) { + state.omzettype = val + }, + update_reporttypes(state, data) { + state.reporttypes = data + }, + update_reporttype(state, val) { + state.reporttype = val + }, + update_agingtypes(state, data) { + state.agingtypes = data + }, + update_agingtype(state, val) { + state.agingtype = val + }, + update_search_status(state, val) { + state.search_status = val + }, + update_statuss(state, data) { + state.statuss = data + }, + update_dialog_status_order(state, val) { + state.dialog_status_order = val + }, + update_get_data_status(state, val) { + state.get_data_status = val + }, + update_get_data_error_message(state, val) { + state.get_data_error_message = val + } + }, + actions: { + async save(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + var data = { + records: resp.data.records, + total: resp.data.total + } + if (data.total !== -1) { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("user/update_alert_success", true, { + root: true + }) + + context.commit("update_dialog_form_report", false) + var msg = "Saran sudah disimpan dong" + context.commit("user/update_msg_success", msg, { + root: true + }) + context.commit("user/update_alert_success", true, { + root: true + }) + context.dispatch("lookup", { + id: prm.userid, + reportgroup: '', + reportcode: '', + reportname: '', + status: prm.filterstatus, + current_page: prm.current_page, + lastid: -1 + }) + } else { + context.commit("update_errors", resp.data.errors) + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async saveaddeditreport(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.saveaddeditreport(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + var data = { + records: resp.data.records, + total: resp.data.total + } + if (data.total !== -1) { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("user/update_alert_success", true, { + root: true + }) + + context.commit("update_dialog_form_report", false) + var msg = '' + if(prm.status === 'N'){ + msg = "Laporan "+prm.name+" batal dipilih" + }else{ + msg = "Laporan "+prm.name+" berhasil dipilih" + } + context.commit("user/update_msg_success", msg, { + root: true + }) + context.commit("user/update_alert_success", true, { + root: true + }) + context.dispatch("lookup", { + id: prm.userid, + reportgroup: prm.reportgroup, + reportcode: prm.reportcode, + reportname: prm.reportname, + status: prm.filterstatus, + current_page: prm.current_page, + lastid: -1 + }) + } else { + context.commit("update_errors", resp.data.errors) + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async saveallreportdetail(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.saveallreportdetail(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + var data = { + records: resp.data.records, + total: resp.data.total + } + if (data.total !== -1) { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("user/update_alert_success", true, { + root: true + }) + + context.commit("update_dialog_form_report", false) + var msg = "Saran sudah disimpan dong" + context.commit("user/update_msg_success", msg, { + root: true + }) + context.commit("user/update_alert_success", true, { + root: true + }) + context.dispatch("lookup", { + id: prm.userid, + current_page: 1, + lastid: -1 + }) + } else { + context.commit("update_errors", resp.data.errors) + } + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async lookupx(context, prm) { + context.commit("update_lookup_report", 1) + try { + let resp = await api.lookupx(one_token(), prm.id) + if (resp.status != "OK") { + context.commit("update_lookup_report", 3) + } else { + context.commit("update_lookup_report", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_reports", data.records) + } + } catch (e) { + context.commit("update_lookup_report", 3) + } + }, + async lookup(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.lookup(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_reports", data.records) + console.log('status') + console.log(data.records.statuss) + context.commit("update_statuss", data.records.statuss) + context.commit("update_total_data", data.total) + + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async lookupbyname(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.lookupbyname(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + } else { + context.commit("update_save_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_reports", data.records) + console.log(data.records) + context.commit("update_total_data", data.total) + } + } catch (e) { + context.commit("update_save_status", 3) + } + }, + async getstatus(context) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.getstatus(one_token()) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + } else { + context.commit("update_get_data_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_f_statuss", data.records.f_statuss) + context.commit("update_selected_filter_status", data.records.f_statuss[0]) + prm.status = data.records.f_statuss[0].M_StatusID + // context.dispatch("lookupbyname", prm) + } + } catch (e) { + context.commit("update_get_data_status", 3) + } + }, + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + let resp = await api.xdelete(one_token(), prm.xid) + if (resp.status != "OK") { + context.commit("user/update_save_status", 3, { + root: true + }) + context.commit("user/update_save_error_message", resp.message, { + root: true + }) + } else { + context.commit("user/update_save_status", 2, { + root: true + }) + context.commit("user/update_save_error_message", resp.message, { + root: true + }) + context.commit("user/update_alert_success", true, { + root: true + }) + + //context.commit("update_dialog_form_schedule_promise", false) + var msg = "Pemeriksaan sudah dihapus dong" + context.commit("user/update_msg_success", msg, { + root: true + }) + context.commit("user/update_alert_success", true, { + root: true + }) + context.dispatch("lookupbyname", { + user: prm.suser, + report: prm.sreport, + current_page: 1, + lastid: -1 + }) + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async searchuser(context,prm) { + context.commit("user/update_autocomplete_status",1,{root: true}) + try { + prm.token = one_token() + let resp= await api.searchuser(prm) + if (resp.status != "OK") { + context.commit("user/update_autocomplete_status",3,{root: true}) + } else { + context.commit("user/update_autocomplete_status",2,{root: true}) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_autousers",resp.data.records) + } + } catch(e) { + context.commit("user/update_autocomplete_status",3,{root: true}) + } + }, + async searchcity(context,prm) { + context.commit("user/update_autocomplete_status",1,{root: true}) + try { + prm.token = one_token() + let resp= await api.searchcity(prm) + if (resp.status != "OK") { + context.commit("user/update_autocomplete_status",3,{root: true}) + } else { + context.commit("user/update_autocomplete_status",2,{root: true}) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_autocitys",resp.data.records) + } + } catch(e) { + context.commit("user/update_autocomplete_status",3,{root: true}) + } + }, + async searchdistrict(context,prm) { + context.commit("user/update_autocomplete_status",1,{root: true}) + try { + prm.token = one_token() + let resp= await api.searchdistrict(prm) + if (resp.status != "OK") { + context.commit("user/update_autocomplete_status",3,{root: true}) + } else { + context.commit("user/update_autocomplete_status",2,{root: true}) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_autodistricts",resp.data.records) + } + } catch(e) { + context.commit("user/update_autocomplete_status",3,{root: true}) + } + }, + async searchkelurahan(context,prm) { + context.commit("user/update_autocomplete_status",1,{root: true}) + try { + prm.token = one_token() + let resp= await api.searchkelurahan(prm) + if (resp.status != "OK") { + context.commit("user/update_autocomplete_status",3,{root: true}) + } else { + context.commit("user/update_autocomplete_status",2,{root: true}) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_autokelurahans",resp.data.records) + } + } catch(e) { + context.commit("user/update_autocomplete_status",3,{root: true}) + } + }, + async searchtest(context,prm) { + context.commit("user/update_autocomplete_status",1,{root: true}) + try { + prm.token = one_token() + let resp= await api.searchtest(prm) + if (resp.status != "OK") { + context.commit("user/update_autocomplete_status",3,{root: true}) + } else { + context.commit("user/update_autocomplete_status",2,{root: true}) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_autotests",resp.data.records) + } + } catch(e) { + context.commit("user/update_autocomplete_status",3,{root: true}) + } + }, + async searchmou(context,prm) { + context.commit("user/update_autocomplete_status",1,{root: true}) + try { + prm.token = one_token() + let resp= await api.searchmou(prm) + if (resp.status != "OK") { + context.commit("user/update_autocomplete_status",3,{root: true}) + } else { + context.commit("user/update_autocomplete_status",2,{root: true}) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_automous",resp.data.records) + } + } catch(e) { + context.commit("user/update_autocomplete_status",3,{root: true}) + } + }, + async searchdoctor(context,prm) { + context.commit("user/update_autocomplete_status",1,{root: true}) + try { + prm.token = one_token() + let resp= await api.searchdoctor(prm) + if (resp.status != "OK") { + context.commit("user/update_autocomplete_status",3,{root: true}) + } else { + context.commit("user/update_autocomplete_status",2,{root: true}) + let data = { + records : resp.data.records, + total: resp.data.total + } + context.commit("update_autodoctors",resp.data.records) + } + } catch(e) { + context.commit("user/update_autocomplete_status",3,{root: true}) + } + }, + async selectaddressdoctor(context,prm) { + context.commit("update_get_data_status", 1) + try { + prm.token = one_token() + let resp = await api.selectaddressdoctor(prm) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + context.commit("update_get_data_error_message", resp.message) + } else { + context.commit("update_get_data_status", 2) + context.commit("update_get_data_error_message", "") + context.commit("update_addressdoctors", resp.data.records.addressdoctors) + } + } catch (e) { + context.commit("update_get_data_status", 3) + context.commit("update_get_data_error_message", e.message) + console.log(e) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/one-report-usergroup/modules/user.js b/test/vuex/one-report-usergroup/modules/user.js new file mode 100644 index 0000000..26e50e0 --- /dev/null +++ b/test/vuex/one-report-usergroup/modules/user.js @@ -0,0 +1,577 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/user.js" + +export default { + namespaced: true, + state: { + last_id: -1, + act: 'new', + lookup_user: 0, + lookup_error_message: '', + users: [], + total_users: 0, + total_filter_users: 0, + selected_user: { + name: "" + }, + save_status: 0, + save_error_message: '', + dialog_form_user: false, + dialog_edit_form_user: false, + alert_success: false, + msg_success: "", + show_all: 'N', + errors: [], + usertypes: [], + usertype: {}, + doctors: [], + doctor: {}, + get_data_status: 0, + get_data_error_message: '', + cities: [], + detail_address: {}, + autocomplete_status: 0, + search_status: 0, + districts: [], + district_address: {}, + kelurahans: [], + kelurahan_address: {}, + instruments: [], + instrument: {}, + autotemplates: [], + autotemplate: {}, + nonlabs: [], + selected_nonlab: {}, + current_page: 1, + x_search: '', + selected_filter_sex: {}, + selected_filter_flag: {}, + f_sexs: [], + f_flags: [] + }, + mutations: { + update_selected_filter_sex(state, val) { + state.selected_filter_sex = val + }, + update_selected_filter_flag(state, val) { + state.selected_filter_flag = val + }, + update_f_sexs(state, val) { + state.f_sexs = val + }, + update_f_flags(state, val) { + state.f_flags = val + }, + update_x_search(state, val) { + state.x_search = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_last_id(state, val) { + state.last_id = val + }, + update_act(state, val) { + state.act = val + }, + update_errors(state, val) { + state.errors = val + }, + update_show_all(state, val) { + state.show_all = val + }, + update_lookup_error_message(state, status) { + state.lookup_error_message = status + }, + update_lookup_user(state, status) { + state.lookup_user = status + }, + update_users(state, data) { + state.users = data.records + state.total_users = data.total + state.total_filter_users = data.total_filter + }, + update_selected_user(state, val) { + state.selected_user = val + }, + update_save_status(state, val) { + state.save_status = val + }, + update_save_error_message(state, val) { + state.save_error_message = val + }, + update_dialog_form_user(state, val) { + state.dialog_form_user = val + }, + update_dialog_edit_form_user(state, val) { + state.dialog_edit_form_user = val + }, + update_alert_success(state, val) { + state.alert_success = val + }, + update_msg_success(state, val) { + state.msg_success = val + }, + update_usertypes(state, data) { + state.usertypes = data + }, + update_usertype(state, val) { + state.usertype = val + }, + update_doctors(state, data) { + state.doctors = data + }, + update_doctor(state, val) { + state.doctor = val + }, + update_get_data_status(state, val) { + state.get_data_status = val + }, + update_get_data_error_message(state, val) { + state.get_data_error_message = val + }, + update_cities(state, val) { + state.cities = val + }, + update_detail_address(state, val) { + state.detail_address = val + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val + }, + update_districts(state, val) { + state.districts = val + }, + update_district_address(state, val) { + state.district_address = val + }, + update_kelurahans(state, val) { + state.kelurahans = val + }, + update_kelurahan_address(state, val) { + state.kelurahan_address = val + }, + update_instruments(state, data) { + state.instruments = data + }, + update_instrument(state, val) { + state.instrument = val + }, + update_autotemplates(state, data) { + state.autotemplates = data + }, + update_autotemplate(state, val) { + state.autotemplate = val + }, + update_nonlabs(state, val) { + state.nonlabs = val + }, + update_selected_nonlab(state, val) { + state.selected_nonlab = val + } + + + }, + actions: { + async lookup(context, prm) { + context.commit("update_lookup_user", 1) + try { + prm.token = one_token() + let resp = await api.lookup(prm) + if (resp.status != "OK") { + context.commit("update_lookup_user", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_user", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total, + total_filter: resp.data.total_filter + } + context.commit("update_users", data) + } + } catch (e) { + context.commit("update_lookup_user", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async lookupbyname(context, prm) { + context.commit("update_lookup_user", 1) + try { + prm.token = one_token() + let resp = await api.lookupbyname(prm) + if (resp.status != "OK") { + context.commit("update_lookup_user", 3) + context.commit("update_lookup_error_message", resp.message) + } else { + context.commit("update_lookup_user", 2) + context.commit("update_lookup_error_message", "") + let data = { + records: resp.data.records, + total: resp.data.total, + total_filter: resp.data.total_filter + } + context.commit("update_users", data) + if (prm.lastid === -1) { + var pat = data.records[0] + context.commit("update_selected_user", data.records[0]) + if (prm.user != "") { + context.dispatch("report/lookup", { + id: pat.id, + reportina: '', + reporteng: '', + status: 'A', + current_page: 1, + lastid: -1 + }, { + root: true + }) + context.commit("detail/update_autousers", [{ + Nat_NormalValueID: pat.Nat_NormalValueID, + Nat_NormalValueName: pat.Nat_NormalValueName + }], { + root: true + }) + context.commit("detail/update_autouser", { + Nat_NormalValueID: pat.Nat_NormalValueID, + Nat_NormalValueName: pat.Nat_NormalValueName + }, { + root: true + }) + } + }else{ + var pat = data.records[prm.lastid] + context.commit("update_selected_user", data.records[prm.lastid]) + if (prm.user != "") { + context.dispatch("report/lookup", { + id: pat.id, + reportina: '', + reporteng: '', + status: 'A', + current_page: 1, + lastid: -1 + }, { + root: true + }) + context.commit("detail/update_autousers", [{ + Nat_NormalValueID: pat.Nat_NormalValueID, + Nat_NormalValueName: pat.Nat_NormalValueName + }], { + root: true + }) + context.commit("detail/update_autouser", { + Nat_NormalValueID: pat.Nat_NormalValueID, + Nat_NormalValueName: pat.Nat_NormalValueName + }, { + root: true + }) + } + } + + + } + } catch (e) { + context.commit("update_lookup_user", 3) + context.commit("update_lookup_error_message", e.message) + } + }, + async getsexreg(context) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.getsexreg(one_token()) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + } else { + context.commit("update_get_data_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_f_sexs", data.records.f_sexs) + context.commit("update_f_flags", data.records.f_flags) + context.commit("report/update_f_statuss", data.records.f_statuss,{ + root: true + }) + context.commit("update_selected_filter_sex", data.records.f_sexs[0]) + context.commit("update_selected_filter_flag", data.records.f_flags[0]) + context.commit("report/update_selected_filter_status", data.records.f_statuss[0],{ + root: true + }) + prm.sexid = data.records.f_sexs[0].Nat_SexID + prm.flagid = data.records.f_flags[0].Nat_FlagID + context.dispatch("lookupbyname", prm) + } + } catch (e) { + context.commit("update_get_data_status", 3) + } + }, + async save(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.save(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_save_error_message", resp.message) + var data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_errors", []) + context.commit("update_alert_success", true) + context.commit("update_dialog_form_user", false) + var msg = "Kelompok Hasil" + prm.name + " sudah tersimpan dong ..." + context.commit("update_msg_success", msg) + context.dispatch("lookupbyname", { + user: prm.suser, + detail: prm.sdetail, + district: prm.sdistrict, + kelurahan: prm.skelurahan, + current_page: 1, + lastid: -1 + }) + } else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async update(context, prm) { + context.commit("update_save_status", 1) + try { + prm.token = one_token() + let resp = await api.update(prm) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_save_error_message", resp.message) + let data = { + records: resp.data.records, + total: resp.data.total + } + + if (data.total !== -1) { + context.commit("update_alert_success", true) + context.commit("update_dialog_form_user", false) + var msg = "Kelompok Hasil" + prm.name + " sudah terupdate dong ..." + context.commit("update_msg_success", msg) + context.dispatch("lookupbyname", { + user: prm.suser, + detail: prm.sdetail, + district: prm.sdistrict, + kelurahan: prm.skelurahan, + current_page: 1, + lastid: -1 + }) + } else { + context.commit("update_errors", resp.data.errors) + + } + + } + } catch (e) { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", e.message) + console.log(e) + } + }, + async delete(context, prm) { + context.commit("update_save_status", 1) + try { + let resp = await api.xdelete(one_token(), prm.userid) + if (resp.status != "OK") { + context.commit("update_save_status", 3) + context.commit("update_save_error_message", resp.message) + } else { + context.commit("update_save_status", 2) + context.commit("update_save_error_message", resp.message) + context.commit("update_alert_success", true) + + var msg = "Kelompok Hasil" + prm.name + " sudah dihapus dong" + context.commit("update_msg_success", msg) + context.commit("update_alert_success", true) + context.commit("update_selected_user", {}) + context.dispatch("lookupbyname", { + user: prm.suser, + detail: prm.sdetail, + current_page: 1, + lastid: -1 + }) + context.dispatch("detail/lookupbyname", { + user: prm.suser, + detail: prm.sdetail, + current_page: 1, + lastid: -1 + }, { + root: true + }) + } + } catch (e) { + context.commit("update_save_status", 3) + console.log(e) + } + }, + async selectnonlab(context) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.selectnonlab(one_token()) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + context.commit("update_get_data_error_message", resp.message) + } else { + context.commit("update_get_data_status", 2) + context.commit("update_get_data_error_message", "") + context.commit("update_nonlabs", resp.data.records.nonlabs) + } + } catch (e) { + context.commit("update_get_data_status", 3) + context.commit("update_get_data_error_message", e.message) + console.log(e) + } + }, + async selectdoctor(context) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.selectdoctor(one_token()) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + context.commit("update_get_data_error_message", resp.message) + } else { + context.commit("update_get_data_status", 2) + context.commit("update_get_data_error_message", "") + context.commit("update_doctors", resp.data.records.doctors) + } + } catch (e) { + context.commit("update_get_data_status", 3) + context.commit("update_get_data_error_message", e.message) + console.log(e) + } + }, + async searchdetail(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.searchdetail(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_cities", resp.data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + } + }, + async searchdoctor(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.searchdoctor(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_doctors", resp.data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + } + }, + async searchinstrument(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.searchinstrument(one_token(), prm.tes) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_instruments", resp.data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + } + }, + async searchtemplate(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.searchtemplate(one_token(), prm.tes) + if (resp.status != "OK") { + context.commit("update_autocomplete_status", 3) + } else { + context.commit("update_autocomplete_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_autotemplates", resp.data.records) + } + } catch (e) { + context.commit("update_autocomplete_status", 3) + } + }, + async getdistrict(context, prm) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.getdistrict(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + } else { + context.commit("update_get_data_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_districts", resp.data.records) + } + } catch (e) { + context.commit("update_get_data_status", 3) + } + }, + async getkelurahan(context, prm) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.getkelurahan(one_token(), prm) + if (resp.status != "OK") { + context.commit("update_get_data_status", 3) + } else { + context.commit("update_get_data_status", 2) + let data = { + records: resp.data.records, + total: resp.data.total + } + context.commit("update_kelurahans", resp.data.records) + } + } catch (e) { + context.commit("update_get_data_status", 3) + } + } + } +} \ No newline at end of file diff --git a/test/vuex/one-report-usergroup/store.js b/test/vuex/one-report-usergroup/store.js new file mode 100644 index 0000000..ba7c8f8 --- /dev/null +++ b/test/vuex/one-report-usergroup/store.js @@ -0,0 +1,25 @@ +// State +// data ... +// Mutations +// +// +// Actions +import user from "./modules/user.js"; +import report from "./modules/report.js"; +import system from "../../../apps/modules/system/system.js"; +export const store = new Vuex.Store({ + modules: { + user: user, + report: report, + system:system + }, + state: { + + }, + mutations: { + + }, + actions: { + + } +}); \ No newline at end of file diff --git a/test/vuex/one-report-v9/api/report.js b/test/vuex/one-report-v9/api/report.js new file mode 100644 index 0000000..bcdbd9d --- /dev/null +++ b/test/vuex/one-report-v9/api/report.js @@ -0,0 +1,97 @@ +const URL = "/one-api/v1/report-v9/main/"; +const dUrl = "/one-api/v1/report-v9/lookup/dropdown/"; +const aUrl = "/one-api/v1/report-v9/lookup/ac/"; + +export async function list(search) { + try { + var resp = await axios.post(URL + 'list',{token: window.one_token(), search}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } +} +export async function lookupparam(prm) { + try { + var resp = await axios.post(URL + 'lookupparam',prm); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } +export async function detail(id) { + try { + var resp = await axios.post(URL + 'detail',{id:id,token: window.one_token()}); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } +} + export async function listdropdown(sp) { + try { + var resp = await axios.post(dUrl + sp); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp.data; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } + export async function listautocomplete(prm) { + try { + var sp = prm.sp + var search = prm.search + var resp = await axios.post(aUrl + sp , + {search: prm.search, dep: prm.dep , value: prm.value} ); + if (resp.status != 200) { + return { + status: "ERR", + message: resp.statusText + }; + } + let data = resp; + return data; + } catch(e) { + return { + status: "ERR", + message: e.message + }; + } + } diff --git a/test/vuex/one-report-v9/components/oneDatePicker2.vue b/test/vuex/one-report-v9/components/oneDatePicker2.vue new file mode 100644 index 0000000..d61bc69 --- /dev/null +++ b/test/vuex/one-report-v9/components/oneDatePicker2.vue @@ -0,0 +1,66 @@ + + + \ No newline at end of file diff --git a/test/vuex/one-report-v9/components/oneReport.vue b/test/vuex/one-report-v9/components/oneReport.vue new file mode 100644 index 0000000..b263ac9 --- /dev/null +++ b/test/vuex/one-report-v9/components/oneReport.vue @@ -0,0 +1,564 @@ + + + + + diff --git a/test/vuex/one-report-v9/components/oneReport0.vue b/test/vuex/one-report-v9/components/oneReport0.vue new file mode 100644 index 0000000..6efef42 --- /dev/null +++ b/test/vuex/one-report-v9/components/oneReport0.vue @@ -0,0 +1,394 @@ + + + + + diff --git a/test/vuex/one-report-v9/index.php b/test/vuex/one-report-v9/index.php new file mode 100644 index 0000000..0e63735 --- /dev/null +++ b/test/vuex/one-report-v9/index.php @@ -0,0 +1,101 @@ + + + + + + + + One + + + + + +
+ + +
+ + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + diff --git a/test/vuex/one-report-v9/modules/report.js b/test/vuex/one-report-v9/modules/report.js new file mode 100644 index 0000000..ea2f2d1 --- /dev/null +++ b/test/vuex/one-report-v9/modules/report.js @@ -0,0 +1,257 @@ +// 1 => LOADING +// 2 => DONE +// 3 => ERROR +import * as api from "../api/report.js" +window.api = api + +export default { + namespaced: true, + state: { + loading: false, + reports: [], + report: {}, + error: '', + details: [], + detail: [], + loading_detail: false, + error_detail: '', + params: [], + total_params: 0, + total_filter_params: 0, + search_status: 0, + current_page: 1, + get_data_status: 0, + get_data_error_message: '', + reportautocompletes: [], + // defaultdetailcompanymodel:{id:0}, + // defaultdetailregionalmodel:{id:0}, + // defaultdetailbranchmodel:{id:0}, + // defaultdetailcompanyitems:[{id:0}], + // defaultdetailregionalitems:[{id:0}], + // defaultdetailbranchitems:[{id:0}], + autocomplete_status: 0 + }, + mutations: { + update_defaultdetailcompanymodel(state, val) { + state.defaultdetailcompanymodel = val + }, + update_defaultdetailcompanyitems(state, val) { + state.defaultdetailcompanyitems = val + }, + update_defaultdetailregionalmodel(state, val) { + state.defaultdetailcompanymodel = val + }, + update_defaultdetailregionalitems(state, val) { + state.defaultdetailcompanyitems = val + }, + update_defaultdetailbranchmodel(state, val) { + state.defaultdetailcompanymodel = val + }, + update_defaultdetailbranchitems(state, val) { + state.defaultdetailcompanyitems = val + }, + update_loading(state, status) { + state.loading = status + }, + update_reports(state, val) { + state.reports = val + }, + update_report(state, report) { + state.report = report + }, + update_error(state, val) { + state.error = val + }, + update_details(state, val) { + state.details = val + }, + update_detail(state, data) { + state.detail = data.detail + }, + update_loading_detail(state, val) { + state.loading_detail = val + }, + update_error_detail(state, val) { + state.error_detail = val + }, + update_params(state, val) { + state.params = val + }, + update_total_params(state, val) { + state.total_params = val + }, + update_total_filter_params(state, val) { + state.total_filter_params = val + }, + update_current_page(state, val) { + state.current_page = val + }, + update_get_data_status(state, val) { + state.get_data_status = val + }, + update_get_data_error_message(state, val) { + state.get_data_error_message = val + }, + update_reportdropdowns(state, val) { + state.reportdropdowns = val + }, + update_reportdropdown(state, val) { + state.reportdropdown = val + }, + update_reportautocompletes(state, val) { + state.reportautocompletes = val + }, + update_autocomplete_status(state, val) { + state.autocomplete_status = val + } + }, + actions: { + async list(context, prm) { + context.commit("update_loading", true) + try { + let resp = await api.list(prm) + if (resp.statusText != "OK") { + context.commit("update_loading", false) + context.commit("update_error", resp.message) + } else { + context.commit("update_loading", false) + context.commit("update_error", "") + context.commit("update_reports", resp.data.data.records) + } + } catch (e) { + context.commit("update_loading", false) + context.commit("update_error", e.message) + } + }, + async lookupparam(context, prm) { + context.commit("update_loading", true) + try { + prm.token = one_token() + let resp = await api.lookupparam(prm) + if (resp.statusText != "OK") { + context.commit("update_loading", false) + context.commit("update_error", resp.message) + } else { + context.commit("update_loading", false) + context.commit("update_error", "") + let data = { + records: resp.data.records, + total: resp.data.total, + total_filter: resp.data.total_filter + } + + context.commit("update_params", resp.data.data.records) + context.commit("update_total_params", resp.data.data.total) + context.commit("update_total_filter_params", resp.data.data.total_filter) + } + } catch (e) { + context.commit("update_loading", false) + context.commit("update_error", e.message) + } + }, + async detail(context, id) { + context.commit("update_loading_detail", true) + try { + let resp = await api.detail(id) + let user = one_user(); + //console.log(resp) + if (resp.statusText != "OK") { + context.commit("update_loading_detail", false) + context.commit("update_error_detail", resp.message) + } else { + context.commit("update_loading_detail", false) + context.commit("update_error_detail", "") + var arrOrders = resp.data.data.records + arrOrders.forEach((value, index) => { + arrOrders[index]["items"] = [] + if (value.R_InputTypeName === 'dropdown') { + var sp = value.R_ReportDetailSourceSp + context.dispatch("listdropdown", { sp: sp, index: index }) + } + if (value.R_InputTypeName === 'company') { + arrOrders[index]['model'] = { id: user.M_BranchCompanyID, name: user.M_BranchCompanyName } + arrOrders[index]['items'] = [{ id: user.M_BranchCompanyID, name: user.M_BranchCompanyName }] + // context.commit("update_defaultdetailcompanymodel",{id: user.M_BranchCompanyID,name: user.M_BranchCompanyName}) + // context.commit("update_defaultdetailcompanymodel",[{id: user.M_BranchCompanyID,name: user.M_BranchCompanyName}]) + } + if (value.R_InputTypeName === 'regional') { + arrOrders[index]['model'] = { id: user.S_RegionalID, name: user.S_RegionalName } + arrOrders[index]['items'] = [{ id: user.S_RegionalID, name: user.S_RegionalName }] + // context.commit("update_defaultdetailregionalmodel",{id: user.S_RegionalID,name: user.S_RegionalName}) + // context.commit("update_defaultdetailregionalmodel",[{id: user.S_RegionalID,name: user.S_RegionalName}]) + } + if (value.R_InputTypeName === 'branch') { + var sp = value.R_ReportDetailSourceSp + context.dispatch("listdropdown", { sp: sp, index: index }) + // console.log("user", user) + // if(user.M_BranchID !== 0 && user.M_BranchName !== ""){ + // console.log("masuk") + // // arrOrders[index]['model'] = {id: user.M_BranchBranchID,name: user.M_BranchBranchName} + // arrOrders[index]['items'] = [{id: user.M_BranchBranchID,name: user.M_BranchBranchName}] + // } + + // context.commit("update_defaultdetailbranchmodel",{id: user.M_BranchBranchID,name: user.M_BranchBranchName}) + // context.commit("update_defaultdetailbranchmodel",[{id: user.M_BranchBranchID,name: user.M_BranchBranchName}]) + } + }); + context.commit("update_details", arrOrders) + } + } catch (e) { + context.commit("update_loading_detail", false) + context.commit("update_error_detail", e.message) + } + }, + async listdropdown(context, param) { + context.commit("update_get_data_status", 1) + try { + let resp = await api.listdropdown(param.sp) + //disimpan dalam report detail + let user = one_user(); + let arrOrders = context.state.details + arrOrders[param.index].items = resp + context.commit("update_details", arrOrders) + + if (arrOrders[param.index].R_ReportDetailR_InputTypeID == 7) { + let new_list = arrOrders[param.index]['items'] + let new_items = [] + //Masuk sebagai cabang + if (user.M_BranchID !== 0 && user.M_BranchName !== "") { + new_list.forEach((value) => { + if (value.id == user.M_BranchID) { + new_items.push({ code: value.code, name: value.name }); + arrOrders[param.index]['model'] = { code: value.code, name: value.name }; + arrOrders[param.index]['items'] = [{ code: value.code, name: value.name }]; + } + }); + } + // Masuk sebagai regional + if (user.M_BranchID == 0 && user.M_BranchName == "") { + new_list.forEach((value) => { + if (value.regionalID == user.S_RegionalID) { + new_items.push({ code: value.code, name: value.name }); + } + }); + arrOrders[param.index]['items'] = new_items; // Update items dengan hasil filtering + } + } + } catch (e) { + context.commit("update_get_data_status", 3) + context.commit("update_get_data_error_message", e.message) + console.log(e) + } + }, + async listautocomplete(context, prm) { + context.commit("update_autocomplete_status", 1) + try { + let resp = await api.listautocomplete(prm) + context.commit("update_autocomplete_status", 2) + let arrOrders = context.state.details + arrOrders[prm.index].items = resp.data + context.commit("update_details", arrOrders) + } catch (e) { + context.commit("update_autocomplete_status", 3) + console.log(e) + } + } + } +} diff --git a/test/vuex/one-report-v9/store.js b/test/vuex/one-report-v9/store.js new file mode 100644 index 0000000..5d8d32c --- /dev/null +++ b/test/vuex/one-report-v9/store.js @@ -0,0 +1,15 @@ +// State +// data ... +// Mutations +// +// +// Actions +import report from "./modules/report.js"; +import system from "../../../apps/modules/system/system.js"; + +export const store = new Vuex.Store({ + modules : { + report:report, + system: system + } +});