|
@@ -1,82 +0,0 @@
|
|
-const state = {
|
|
|
|
- customers: [],
|
|
|
|
- filtered: [],
|
|
|
|
- selectedCustomerInvoices: [],
|
|
|
|
- selectedCustomer: null
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const getters ={
|
|
|
|
- customers(state){
|
|
|
|
- return state.filtered.length === 0 ? state.customers : state.filtered
|
|
|
|
- },
|
|
|
|
- hasSelectedCustomer(state){
|
|
|
|
- return !!state.selectedCustomer
|
|
|
|
- },
|
|
|
|
- selectedCustomer(state){
|
|
|
|
- return state.selectedCustomer
|
|
|
|
- },
|
|
|
|
- customerInvoices(state){
|
|
|
|
- return state.selectedCustomerInvoices
|
|
|
|
- },
|
|
|
|
- customerMoveLine(state){
|
|
|
|
- let moveline= []
|
|
|
|
- state.selectedCustomerInvoices.forEach(item =>{
|
|
|
|
- moveline.push(item.movelines);
|
|
|
|
- })
|
|
|
|
- return !! moveline ? moveline : []
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const mutations ={
|
|
|
|
- pushCustomers(state, payload){
|
|
|
|
- state.customers =[ ...payload.customers]
|
|
|
|
- },
|
|
|
|
- selectCustomer(state, payload){
|
|
|
|
- state.selectedCustomer = payload.customer
|
|
|
|
- },
|
|
|
|
- selectCustomerInvoices(state, payload){
|
|
|
|
- state.selectedCustomerInvoices = state.selectedCustomer.invoices
|
|
|
|
- },
|
|
|
|
- applyCustomersFilter(state, payload){
|
|
|
|
- state.filtered = payload
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const actions ={
|
|
|
|
- fetchCustomers({ commit, dispatch }){
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
- let ResPartner = new openerp.web.Model('res.partner')
|
|
|
|
-
|
|
|
|
- ResPartner.call('get_customers',{
|
|
|
|
- context: new openerp.web.CompoundContext()
|
|
|
|
- }).then(response => {
|
|
|
|
- commit('pushCustomers',{
|
|
|
|
- customers: response
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- dispatch('loaded', 'customers')
|
|
|
|
-
|
|
|
|
- resolve()
|
|
|
|
- }).fail(error => {
|
|
|
|
- console.log(error)
|
|
|
|
- reject(error)
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- selectCustomer({ commit }, payload){
|
|
|
|
- commit('selectCustomer',{
|
|
|
|
- customer: payload
|
|
|
|
- })
|
|
|
|
- commit('selectCustomerInvoices')
|
|
|
|
- },
|
|
|
|
- filterCustomers({ commit },payload){
|
|
|
|
- commit('applyCustomersFilter', payload)
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-export default {
|
|
|
|
- state,
|
|
|
|
- getters,
|
|
|
|
- mutations,
|
|
|
|
- actions
|
|
|
|
-}
|
|
|