123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- import axios from 'axios'
- const actions = {
- notify(_, message) {
- openerp.web.notification.do_warn('Atencion', message)
- return false
- },
- initProcessBank({ getters, commit, dispatch}, mode) {
- commit('setMode', mode || getters.mode)
- return axios.get('/eiru_bank_statement/init', {
- params: {
- mode: getters.mode
- }
- }).then(({data}) => {
- dispatch('explodeData', data)
- }).catch(error => {
- console.error(error);
- })
- },
- explodeData({ dispatch }, data) {
- for (let value in data) {
- dispatch(`init${value[0].toUpperCase()}${value.slice(1)}`, data[value]);
- }
- },
- /* Check Statement */
- checkStatement({ getters, dispatch }) {
- return !!getters.selectedStatement || dispatch('notify', 'Necesitas seleccionar una caja para continuar');
- },
- /* Check Statement Dest */
- checkStatementDest({ getters, dispatch }) {
- return !!getters.selectedStatementDest || dispatch('notify', 'Necesitas seleccionar una caja para la transferencia')
- },
- /*
- checkAmount({ getters, dispatch}) {
- return getters.amountOperation > 0 || dispatch('notify', 'El valor de la operación debe ser mayor que “0”.')
- },*/
- //
- // description
- /* Fin del processo */
- endProcess({getters, commit, dispatch}) {
- let data = {}
- if (getters.isTransfer || getters.isInputCashbox || getters.isOutputCashbox) {
- console.log("Transferencia, entrada o Salida")
- /* Verift Amount Operation */
- if (getters.amountOperation <= 0) {
- dispatch('notify', 'El valor de la operación debe ser mayor que “0”.')
- return false
- }
- /* Verify Description */
- if (!getters.description.trim()) {
- dispatch('notify', 'Necesitas ingresar una observación para la operación.')
- return false
- }
- /* Generate Data */
- data = {
- transfer: getters.isTransfer,
- input: getters.isInputCashbox,
- output: getters.isOutputCashbox,
- amount: getters.amountOperation,
- description: getters.description,
- casboxOriginId: getters.selectedStatement.id,
- casboxDestID: !!getters.selectedStatementDest ? getters.selectedStatementDest.id: '',
- }
- commit('setDataEndProcess', data)
- dispatch('createCasboxMove')
- }
- if (getters.isStatmentConfirm) {
- console.log("CIERRE ")
- let data = {}
- if (!getters.description.trim()) {
- dispatch('notify', 'Necesitas ingresar una observación para el cierre de caja.')
- return false
- }
- data = {
- statementId: getters.selectedStatement.id,
- amount: getters.amountOperation,
- description: getters.description,
- }
- commit('setDataEndProcess', data)
- dispatch('processClosingStatement')
- }
- },
- /**
- * [createCasboxMove ]
- * # Transferencia
- * # input
- * # Output
- */
- createCasboxMove({ getters, dispatch, commit }) {
- return axios.post('/eiru_bank_statement/create_cashbox_move', {
- jsonrpc: '2.0',
- method: 'call',
- params: {
- data: getters.data
- }
- }).then(({data}) => {
- // dispatch('notify', data.result.message)
- }).catch(error => {
- console.error(error)
- })
- },
- processClosingStatement({ getters, dispatch, commit }) {
- return axios.post('/eiru_bank_statement/process_closing_statement', {
- jsonrpc: '2.0',
- method: 'call',
- params: {
- data: getters.data
- }
- }).then(({data}) => {
- dispatch('notify', data.result.message)
- }).catch(error => {
- console.error(error)
- })
- },
- /*
- ____ ____ _____ _ _____ _____ ____ _____ _ _____ _____ __ __ _____ _ _ _____
- / ___| _ \| ____| / \|_ _| ____| / ___|_ _|/ \|_ _| ____| \/ | ____| \ | |_ _|
- | | | |_) | _| / _ \ | | | _| \___ \ | | / _ \ | | | _| | |\/| | _| | \| | | |
- | |___| _ <| |___ / ___ \| | | |___ ___) || |/ ___ \| | | |___| | | | |___| |\ | | |
- \____|_| \_\_____/_/ \_\_| |_____| |____/ |_/_/ \_\_| |_____|_| |_|_____|_| \_| |_|
- */
- endProcessNewStatement({getters, commit, dispatch}){
- let data = {}
- data = {
- journal_id: getters.selectedJournal,
- type_statement: getters.selectedStatementType,
- user_id: getters.selectedUserStatement,
- date: getters.dateStatement,
- }
- commit('setDataEndProcess', data)
- dispatch('createAccountBankStatement')
- },
- /*[CreateAccountBankStatement "Crear Caja"]*/
- createAccountBankStatement({ getters, dispatch, commit}) {
- return axios.post('/eiru_bank_statement/create_account_bank_statement', {
- jsonrpc: '2.0',
- method: 'call',
- params: {
- data: getters.data
- }
- }).then(({data}) => {
- dispatch('notify', data.result.message)
- if (data.result.state){
- dispatch('receiveStatment',data.result.data)
- dispatch('showStatementAdd',false)
- }
- }).catch(error => {
- console.error(error)
- })
- },
- resetStoreModules({ dispatch }, payload) {
- // console.log(payload)
- // console.log(
- // !!getters.isInputCashbox
- // !!getters.isOutputCashbox
- // )
- // if (!!getters.isInputCashbox || !!getters.isOutputCashbox && payload === 1) {
- //
- // }
- // if (payload > 1 ){
- // return
- // }
- // dispatch('resetStatementAction')
- // dispatch('resetStatement')
- // isTransfer
- // isInputCashbox
- // isOutputCashbox
- // resetStatement
- // resetStatementAction
- return
- }
- }
- export default actions
|