Browse Source

[FIX] currency in cart items

Gogs 7 years ago
parent
commit
ef90bf78cc
3 changed files with 18 additions and 3 deletions
  1. 1 1
      src/App.vue
  2. 10 2
      src/components/CartItem.vue
  3. 7 0
      src/components/CartItems.vue

+ 1 - 1
src/App.vue

@@ -6,7 +6,7 @@
                     products-searcher
                     products-grid
                 .cart-container
-                    cart-total(:total="total" :symbol="currency.symbol" :decimals="2")
+                    cart-total(:total="total" :symbol="currency.symbol")
                     cart-items
         tab-content(title="Seleccione un cliente")
             customer-searcher

+ 10 - 2
src/components/CartItem.vue

@@ -3,9 +3,9 @@
             h3.item-name {{ item.display_name }}
             input.item-quantity(type="text" :value="item.qty")
             span.item-x x
-            span.item-price Gs {{ item.list_price }}
+            span.item-price {{ getPrice() }}
             span.item-equals =
-            span.item-subtotal Gs {{ item.list_price * item.qty }}
+            span.item-subtotal {{ getSubtotal() }}
 </template>
 
 <script>
@@ -19,6 +19,14 @@
                 }
             }
         },
+        methods: {
+            getPrice() {
+                return accounting.formatMoney(this.item.list_price, '₲', 0, '.', ',')
+            },
+            getSubtotal() {
+                return accounting.formatMoney(this.item.list_price * this.item.qty, '₲', 0, '.', ',')
+            }
+        },
         mounted() {
             this.$set(this.item, 'qty', 1)
         }

+ 7 - 0
src/components/CartItems.vue

@@ -8,6 +8,13 @@
     import { mapGetters, mapActions } from 'vuex'
 
     export default {
+        props: {
+            decimals: {
+                type: Number,
+                default: 0
+            },
+            
+        },
         components: {
             'cart-item': CartItem
         },