add modules folder based on s_menu
This commit is contained in:
898
test/vuex/acc-one-jurnal/modules/jpbreg.js
Normal file
898
test/vuex/acc-one-jurnal/modules/jpbreg.js
Normal file
@@ -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')
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
821
test/vuex/acc-one-jurnal/modules/jurnalbiaya.js
Normal file
821
test/vuex/acc-one-jurnal/modules/jurnalbiaya.js
Normal file
@@ -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')
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
841
test/vuex/acc-one-jurnal/modules/jurnalgaji.js
Normal file
841
test/vuex/acc-one-jurnal/modules/jurnalgaji.js
Normal file
@@ -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')
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
446
test/vuex/acc-one-jurnal/modules/jurnalumum.js
Normal file
446
test/vuex/acc-one-jurnal/modules/jurnalumum.js
Normal file
@@ -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)
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
404
test/vuex/acc-one-jurnal/modules/pengeluaranbarang.js
Normal file
404
test/vuex/acc-one-jurnal/modules/pengeluaranbarang.js
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
382
test/vuex/acc-one-jurnal/modules/terimaBarang.js
Normal file
382
test/vuex/acc-one-jurnal/modules/terimaBarang.js
Normal file
@@ -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)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user