123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- const initialState = {
- currency: [],
- loadingCurrency: false,
- currencyAmount: []
- }
- const state = {
- currency: initialState.currency,
- loadingCurrency: initialState.loadingCurrency,
- currencyAmount: initialState.currencyAmount
- }
- const getters = {
- /**
- * [currency]
- */
- currency(state) {
- return state.currency
- },
- /**
- * [loadingCurrency]
- */
- loadingCurrency(state) {
- return state.loadingCurrency
- },
- /**
- * [currencyAmount description]
- */
- currencyAmount (state) {
- return state.currencyAmount
- }
- }
- const mutations = {
- /**
- * [currency]
- */
- setCurrencies (state, payload) {
- state.currency = payload
- },
- /**
- * [loadingCurrency]
- */
- setLoadingCurrencies (state, payload) {
- state.loadingCurrency = !!payload
- },
- /**
- * [actions description]
- */
- setCurrenciesAmount (state, payload) {
- let currency = payload.currency
- let currencyMove = payload.currencyMovePayments
- let amountCurrency = []
- currency.forEach(item => {
- let amount = 0
- currencyMove.forEach(currency =>{
- let currencyMoveLine = currency.currencyAmount.find(move => move.id === item.id)
- amount = amount + currencyMoveLine.amountCurencyResidual
- })
- amountCurrency.push({
- id: item.id,
- symbolCurrency: item.symbol,
- amount: amount,
- symbol: ' ',
- position: 'before',
- thousandsSeparator: item.thousandsSeparator,
- decimalSeparator: item.decimalSeparator,
- decimalPlaces: item.decimalPlaces,
- rateSilent: item.rateSilent
- })
- })
- state.currencyAmount = amountCurrency
- }
- }
- const actions = {
- /**
- * [INIT_CURRENCIES]
- */
- initPaymentsCurrencies ({commit}, payload) {
- commit('setCurrencies', payload)
- commit('setLoadingCurrencies', payload)
- },
- /**
- * [currencyInvoiceRate description]
- */
- resetCurrency({ commit }) {
- commit('setCurrencies', [] )
- },
- /**
- * [currencyInvoiceRate description]
- */
- initCurrenciesAmount ({ commit, getters, dispatch}) {
- commit('setCurrenciesAmount', {
- currencyMovePayments: getters.movesPayments,
- currency: getters.currency
- })
- dispatch('resetPayments')
- }
- }
- export default {
- state,
- getters,
- mutations,
- actions
- }
|