Browse Source

[ADD] get currency symbol from company state

Gogs 7 years ago
parent
commit
390845a2d0
3 changed files with 16 additions and 3 deletions
  1. 1 1
      src/App.vue
  2. 11 1
      src/components/SummaryDisplay.vue
  3. 4 1
      src/store/modules/company.js

+ 1 - 1
src/App.vue

@@ -50,7 +50,7 @@
         },
         computed: mapGetters({
             total: 'getTotal',
-            currency: 'getDefaultCurrency'
+            currency: 'getCurrency'
         }),
         methods: mapActions([
             'fetchData'

+ 11 - 1
src/components/SummaryDisplay.vue

@@ -1,10 +1,20 @@
 <template lang="pug">
     .summary
-        h2 Aquí se va un resumen
+        h2 {{ getTotal() }}
 </template>
 
 <script>
+    import { mapGetters } from 'vuex'
+
     export default {
+        computed: mapGetters({
+            total: 'getTotal'
+        }),
+        methods: {
+            getTotal() {
+                return accounting.formatMoney(this.total, '₲', 0, '.', ',')
+            }
+        }
     
     }
 </script>

+ 4 - 1
src/store/modules/company.js

@@ -6,8 +6,11 @@ const getters = {
     getCompany(state) {
         return state.company
     },
-    getDefaultCurrency(state) {
+    getCurrency(state) {
         return state.company ? state.company.currency : ''
+    },
+    getCurrencySymbol(state) {
+        return state.company ? state.company.currency.symbol : '$'
     }
 }